SOLVED: C#.NET X509Certificate: System.InvalidOperationException: 'An X509Extension with OID '2.5.29.15' has already been specified.'

You may see the error "System.InvalidOperationException: 'An X509Extension with OID '2.5.29.15' has already been specified.'" when creating a self signed certificate.

This can occur if you try and add multiple KeyUsageFlags as two separate extensions.

certificateRequest.CertificateExtensions.Add(new X509KeyUsageExtension(X509KeyUsageFlags.KeyEncipherment , true));

certificateRequest.CertificateExtensions.Add(new X509KeyUsageExtension( X509KeyUsageFlags.DigitalSignature, true));

To resolved the issue assign the flags to a single extension.

certificateRequest.CertificateExtensions.Add(new X509KeyUsageExtension(X509KeyUsageFlags.KeyEncipherment | X509KeyUsageFlags.DigitalSignature, true));





Comments

Popular posts from this blog

Windows Server 2016, 2019, 2022, Windows 10 and Windows 11: Date and time "Some settings are managed by your organization".

TFTPD32 or TFTPD64 reports Bind error 10013 An attempt was made to access a socket in a way forbidden by its access permissions.

Enable function lock for F1-F12 on HP ZBook mobile workstations