You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Bug]: X509Certificate2.GetCertificatePublicKey returns public key parameters (modulus and exponent) instead of the key value, and there is no way to obtain the generated public key value from an X509 certificate #4238
Internally, X509Certificate2.GetCertificatePublicKey invokes AsymmetricAlgorithm.ToXmlString(false) which returns an XML representation of the crypto service provider. In case of the RSA provider, this is an XML containing the modulus and the exponent values:
I can use the returned XML to initialize a signature key instance, but can't obtain the public key value that can be sent to a third party to verify a signature. Neither does the SignatureKey codeunit have any methods to extract the public key.
Expected behavior
Codeunit X509Certificate2 should have a method similar to CertificateManagement.GetPublicKeyAsBase64String which is a wrapper around .Net X509Certificate2.GetRawCertData().
Steps to reproduce
For now, the only way to obtain the public key from a certificate is to upload it into the isolated storage and use the "Certificate Management" codeunit, but no method to get the key when the certificate comes from an external source.