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 ));