-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
X509Certificate2/OpenSSL: Unable to open PKCS#12 files with no password and no MAC #18254
Comments
OpenSSL and Windows both use the null password as the empty password when creating PFX files. Does bouncy castle generate a usable file if you specify "" instead of null? |
@bartonjs If I use So that's a workaround for me now. I'd still argue the behavior where |
Not sure if this is related or if I should open a new issue, but I'm having a similar problem. I'm using certs with a password. They work on Windows but fail on Linux. The specific exception message is this:
I created the certificates using OpenSSL on Windows Bash, so I don't know if a MAC entry was included. I can't find any results when trying to search for this subject, all I can get are results about Mac OS. I don't know how to generate a cert that will work on Linux as well as Windows. I used this command to create the cert:
Then this to convert to PFX:
|
@vaindil Yeah, it seems like a separate issue. But, in order to identify if we'd be able to do anything about it you should send that PFX to a Linux machine with the
If that can't read it then it's an OpenSSL library problem, and we won't be able to, either. If it can, then there's a fallback path we're missing. If the command line utility test passes, it'd be great if you could give us a sample PFX that fails. |
@bartonjs Just tested, the Key passphrase ( Generate the key and certificate:
Convert to PFX:
|
We need a test and likely add one more fallback call. |
Any update on this issue , hitting the same error with pfx that is password protected on Ubuntu 16.04. |
@sphiecoh If your PFX has a password that'd be a different problem, since this is specifically about a PFX with a |
nvm I found my issue , password was cleared out of env. |
the mac verify fail also with my Comodo SSL cert, which works fine with other a service. There is something to pass online web server because with "bought" SSL certificate there's not possibility to change the cert-key generation string.. |
Hi, any update on this? |
@jeremyVignelles Nope, sorry. I'm hoping to get the time to rewrite the PFX loader entirely to work around platform-specific quirks like this. The new Pkcs12Info type in .NET Core 3.0 should be capable of exploring (and extracting data from) a PFX in this state, so you might be able to write a loader for your particular needs. https://apisof.net/catalog/System.Security.Cryptography.Pkcs.Pkcs12Info |
I'm seeing the same issue when creating a PFX file from a key and cert with an empty password (enter twice when prompted) or by passing |
This is annoying, & blocks all my work. Do you have any workaround for this? While .NET Core 3.0 not released yet? |
The workaround would be to set a password I guess... EDIT : you can also try with BouncyCastle (the .net core-compatible version) |
@inpicksys What I did is just used a password "password" and stored the credential in the source code with a comment explaining that it's a workaround for a bug and included a link to this thread. It's my intent to use no password protection at all for the certificate and I wanted to capture that intent in there as to not raise any alarms when someone eventually notices it. |
@bartonjs, there's still mention of this issue in the code: runtime/src/libraries/System.Security.Cryptography.Pkcs/tests/Pkcs12/Pkcs12BuilderTests.cs Line 406 in 04f2226
runtime/src/libraries/System.Security.Cryptography.Pkcs/tests/Pkcs12/Pkcs12BuilderTests.cs Line 461 in 04f2226
|
If you have a PKCS#12 file which is not protected with a password, and which does not have a MAC entry, opening the file will work on Windows but fails on Linux and Mac (which use OpenSSL).
The following program reproduces the behavior:
The output on Windows:
and on Linux:
You can get the same error message by running OpenSSL directly on the
rawData.bin
file (don't provide a password):However, OpenSSL will correctly inspect the file if you pass the
-nomacver
option:The issue seems to be caused by the absence of a MAC entry in the file. Based on RFC7292, I believe that's valid, and BouncyCastle creates PKCS#12 files without MAC entries if no password is provided.
So net, because
-nomacver
flagI would expect .NET Core on Linux & Mac to also be able to read this file.
The text was updated successfully, but these errors were encountered: