-
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
error is given to load p7b in X509Certificate2Collection #59304
Comments
Tagging subscribers to this area: @bartonjs, @vcsjones, @krwq, @GrabYourPitchforks Issue DetailsHi,
I tested using following link: I got following result:
|
.NET does not currently support certificates with RSA-PSS (1.2.840.113549.1.1.10) public keys. |
Oh. I see. You are using the Instead, on your X509Certificate2Collection coll = new X509Certificate2Collection();
// put stuff in the collection...
foreach (X509Certificate2 cert in coll)
{
if (cert.GetRSAPublicKey() is RSA rsa)
{
// It's an RSA certificate - use `rsa` here.
}
else if (cert.GetECDsaPublicKey() is ECDsa ecdsa)
{
// It's an ECDsa certificate - use `ecdsa` here.
}
else
{
throw new CryptographicException("Unhandled certificate algorithm");
}
} |
Thank you for informing me about deprecation of PublicKey.Key.
I do not know, maybe I'm wrong. This is also a sample p7b file generated using RSA-PSS and I have no problem reading its public key:
CngKey k = ecdsa.Key;
byte[] blob = k.Export(CngKeyBlobFormat.EccPublicBlob); If I try to read XmlString like the following, I get an error: ecdsa.ToXmlString(ECKeyXmlFormat.Rfc4050); Error:
My Operating System is Windows 10 21H1 and sample p7b file generated using ECDSA is as follows:
How can I get a Public Key as XmlString? |
Yeah. Producing an RSA-PSS signature is supported with an RSA key. However there are X.509 certificates that have special RSA-PSS SubjectPublicKeyInfo's, and that is what I was alluding to not being supported. If you aren't running in to that, great.
The
I think the better thing to do in .NET is to use |
I think the original question, and variants, have been answered (@vcsjones' answers are all correct), so closing the issue. To restate the problems and answers:
|
Hi,
Sometimes in System.Security.Cryptography.X509Certificates.X509Certificate2Collection following error is given to load p7b file:
I tested using following link:
https://pkijs.org/examples/P7BSimpleExample.html
I got following result:
The text was updated successfully, but these errors were encountered: