Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The certificate generated is not applicable for Exchange 2013 #45

Closed
Slamich opened this issue Nov 25, 2019 · 9 comments
Closed

The certificate generated is not applicable for Exchange 2013 #45

Slamich opened this issue Nov 25, 2019 · 9 comments

Comments

@Slamich
Copy link

Slamich commented Nov 25, 2019

Hi.
Generated a certificate using this module.
I get a PFX file that I import in Exchange 2013
It is imported with an invalid CSP provider:
"Microsoft Software Key Storage Provider"
And you need the provider to be:
"Microsoft Enhanced Cryptographic Provider v1.0"
or
"Microsoft RSA SChannel Cryptographic Provider"

Found a solution to work around this problem
openssl.exe pkcs12 -in certificate.pfx -out certificate.pem -nodes
openssl.exe pkcs12 -export -in certificate.pem -out new_certificate.pfx

After that, the certificate is imported with the desired provider:
"Microsoft Enhanced Cryptographic Provider v1.0"

Can you fix it?

@glatzert
Copy link
Collaborator

There might be a possibility during pfx export, but I'm not sure.
Also the CSPs you mention are appearantly "legacy" and MS-centric. The module itself is (or at least should be) x-plat.

If you can provide a PR, which does allow to set the CSP, I'll probably merge it.
I personally will not implement it, and since you have a working solution with openssl, there's no real need to include it in the module.

It'd also be possible to add documentation about import / export needs.

@Slamich
Copy link
Author

Slamich commented Nov 25, 2019

The fact is that there were no such problems with the previous ASMESharp module.

@glatzert
Copy link
Collaborator

Ok. And?

@Slamich
Copy link
Author

Slamich commented Nov 25, 2019

I do not quite understand what you need to provide so that you can turn on the provider.

@glatzert
Copy link
Collaborator

So far I can identify two places, where the provider might be selectable.
The first is the creation of the RSA-Key; the second is the export of the certificate.

This is the RSAKey: https://github.com/PKISharp/ACMESharpCore-PowerShell/blob/master/ACME-PS/internal/classes/crypto/RSAKey.ps1

And this the Export-Certificate internals:
https://github.com/PKISharp/ACMESharpCore-PowerShell/blob/master/ACME-PS/internal/classes/crypto/Certificate.ps1

Just to be clear, about my interests: I'm willing to help on the "merge-into-the-module"-side of things and carry it around in the module until it's not possible anymore, but I have very little interest in digging into the CSP specifics in windows myself - especially when there's already a valid tool (openSSL) to use and solve the problem.

@GeorgeSchiro

This comment has been minimized.

@glatzert
Copy link
Collaborator

@GeorgeSchiro I moved you issue - thanks for pointing out. Discussion is welcome.
@Slamich - I'm sorry, if I was hostile, but I read your comment as "it was like that, and now I want you to implement it that way again" - I only assumed that, but since text is without tone, that might be a blatant misinterpretation of your intend.

If you have ideas how to tackle the problem or want to investigate the matter, I'll help if I can.

@phidevz
Copy link

phidevz commented May 9, 2020

@glatzert to me it seems like it is an "issue" coming from how the Microsoft Crypto library processes the "ExportWithPrivateKey" or whatever the function is called.
It seems that it uses the Cryptography Next Generation (CNG) and that might be the issue. Not sure tho. Maybe you can have at it (https://referencesource.microsoft.com/#System.Core/System/Security/Cryptography/X509Certificates/RSACertificateExtensions.cs) and implement it yourself using the "old" crypto API (not CNG)?

thanks in advance :)

@glatzert
Copy link
Collaborator

glatzert commented May 9, 2020

Currently ACME-PS is written as module, running in Windows Powershell as well as Powershell Core - the latter one being "the future" on all systems - especially when .NET 5.0 will be around.

I don't think, the old crypto API is compatible with .NET Core, meaning I'd probably have to build a special code-path to support the legacy crypto provider on WindowsPowershell only. That seems like a lot of work regarding, you can still use openSSL as a workaround.

Is there a prohibitive reason to not use openSSL?

openssl.exe pkcs12 -in certificate.pfx -out certificate.pem -nodes
openssl.exe pkcs12 -export -in certificate.pem -out new_certificate.pfx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants