-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
X509Store.Add Fails On Ubuntu 22.04 in FIPS Mode #111560
Comments
Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones |
There isn't one.
Yep. Until we figure out a path forward, you'll have to either not export in the PFX format (which this does under the covers) or get out of FIPS mode. |
Sorry if I wasn't clear. I'm aware there isn't an OS-level keychain. I'm just highlighting how this issue is arising on Linux. I've been able to work around this and manage my certificate a different way in the app that's running on the FIPS-mode machine, so this is not causing an ongoing production issue for me. I just wanted to kick off a discussion of the issue and some possible paths forward. I think it's probably fine that the internal store on Linux is exporting to PFX format. The trouble is the 3DES/SHA-1 parameters being used. I know there will be compatibility considerations involved, but AES/SHA-256 would be a more secure (and FIPS-compatible) default. Maybe the algorithm could also be user-parameterizable by passing it as an option in some way to the X509Store, but that would leak Linux-specific implementation details that are irrelevant on Windows and macOS. |
I think it would probably be fine to just use AES+SHA256 in Linux by default only for the The public API Ideally #80314 would be done first, which I am pretty close barring some questions for @bartonjs about where things need to live. If we do that, then it should be a matter of changing this line: Line 215 in 89ef51c
To use the new API. This line: Line 88 in 89ef51c
Already supports reading back in either PBES1 or PBES2 algorithms. |
Hello, Sorry to add to the discussion, but I'm having the same issue on a RedHat environment with FIPS:
My application is now running with .Net 8 but I first observed this issue with .Net 6. I also get this issue when adding certificates to the var filePath = "path/to/cert.pfx";
var certs = new X509Certificate2Collection();
certs.Import(filePath);
foreach (var certificate in certs.Cast<X509Certificate2>())
{
using (var store = new X509Store(storeName, StoreLocation.CurrentUser))
{
store.Open(OpenFlags.ReadWrite);
store.Add(certificate);
store.Close();
}
} I don't understand, however, why the Thank you! |
Because the format we use on X509Store on Linux is a PKCS#12/PFX export.
"Don't use X509Store" or "Don't have FIPS mode engaged" are, unfortunately, the best suggestions at the moment. That's probably tantamount to "no", but I thought I'd be more verbose. |
I see, thank you for the clarification. Unfortunately, I get a similar issue when I try to export a certificate to PFX, like so: certificate.Export(X509ContentType.Pkcs12, (string)null); I get the following error:
Do you know if there is any ETA for this fix? Could I expect a fix for .Net 8 or would it be just in future versions? Thank you! Edit: just found this workaround, I'll give it a try. It would be very nice this new API proposal be implemented, I'm also curious about the ETA for this, if there's any. Thank you! |
Both the new API for |
Description
Calling
X509Store.Add(X509Certificate2 certificate)
in .NET 8 on Ubuntu 22.04 in FIPS Mode fails with anOpenSslCryptographicException
due to 3DES/SHA-1 being unsupported in FIPS mode. It appears the underlying issue is in theOpenSslDirectoryBasedStoreProvider
used byX509Store
on Linux systems. Instead of delegating certificate storage to an OS-level store/keychain, it appears this implementation is storing the certificate and key on the filesystem in PFX format. This export uses 3DES/SHA-1, which to the best of my knowledge is disallowed in FIPS 140-3, which Ubuntu 22.04 complies with.Reproduction Steps
Expected behavior
X509Store.Add
should succeed on Ubuntu 22.04 using a FIPS-supported algorithm like AES/SHA-256.Actual behavior
Stack Trace:
Regression?
No response
Known Workarounds
No response
Configuration
.NET 8
Ubuntu 22.04 in FIPS mode
Other information
See:
OpenSslDirectoryBasedStoreProvider.AddCertToStore(ICertificatePal certPal)
When
OpenSslExportProvider.ExportPkcs8
callsExportEncryptedPkcs8PrivateKey
on the selected algorithm, it passes ins_windowsPbe
, hard-coded parameters that are disallowed in FIPS 140-3:https://github.com/dotnet/runtime/blob/6c58f7992cfd628a53d9b90f258ac123cb803644/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/OpenSslExportProvider.cs#L42C1-L42C2
runtime/src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/UnixExportProvider.cs
Line 20 in 6c58f79
Possibly related issues:
The text was updated successfully, but these errors were encountered: