.NET Class for handling X.509 Certificates
Questions tagged [x509certificate2]
922 questions
8
votes
2 answers
Setting private key in certificate hangs windows service
I have application and I have to use a certificate which requires a pin from prompt window.
I have following code.
SecureString password = GetPassword();
X509Certificate2 certificate = GetCertificate();
var cspParameters = new CspParameters(1,
…

Degusto
- 291
- 2
- 10
8
votes
2 answers
How can I detect the type of a certificate (A1 or A3)?
I have 2 types of certificates on my machine, one A1 and the other is A3, when loading one of them into a X509Certificate2 object, how can I programmatically detect if it's a A1 or A3?
I understand that if the A3 certificate is not plugged in, the…

Nicke Manarin
- 3,026
- 4
- 37
- 79
8
votes
1 answer
How do I get certificate's key size
I have an X.509 certificate and need to get the size of its key (in bits) - e.g., 1024 2048 etc. I have looked at X509Certificate2 and also the bouncycastle X509Certificate classes but can't see how to get the key size.

FunLovinCoder
- 7,597
- 11
- 46
- 57
8
votes
2 answers
Can not find the specified object with X509Certificate2
I'm trying to load a file that contains the secret key to access to Google Calendar API. Following this tutorial.
For doing this I've created this code:
var certificate = new X509Certificate2("client_secret.json", "notasecret",…

Dillinger
- 1,823
- 4
- 33
- 78
8
votes
1 answer
How can I check if a certificate is self-signed?
I'm using C#.NET and need to install a bunch of certificates into the Windows certificate store.
I need to check which of those certificates are root certificates (i.e. self-signed), so I can install them into the "Trusted root certificates"…

MarioDS
- 12,895
- 15
- 65
- 121
8
votes
6 answers
Read Private Key from PFX-file
I know, there are many posts about this, but still I cannot find a solution to get this to work. I have generated a PFX-file with openssl on my machine like this:
openssl x509 -req -days 365 -in "myReqest.csr" -signkey "myPrivateKey.pem" -out…

marsze
- 15,079
- 5
- 45
- 61
7
votes
1 answer
How to Decrypt EncryptedAssertion using System.Cryptography
The Identity provider is encrypting the Saml Assertion using the functions of component pro
Dim encryptedSamlAssertion As New EncryptedAssertion(samlAssertion, encryptingCert, New…

Akshay G
- 2,070
- 1
- 15
- 33
7
votes
3 answers
.NET Framework x509Certificate2 Class, HasPrivateKey == true && PrivateKey == null?
I'm attempting to work with an X509 certificate that was originally imported into the CurrentUser keystore on a Windows 10 computer using the "Certificates" snap-in of an MMC. The same procedure has been tested on a Windows 8.1 computer with the…

Matthew Johnson
- 175
- 1
- 5
7
votes
3 answers
Clean my MachineKeys folder by removing multiple RSA files without touching IIS ones
I'm currently running IIS on my server using an app instantiating certificates.
By doing this code, for instance :
X509Certificate2 myX509Certificate = new
X509Certificate2(Convert.FromBase64String(byteArrayRawCertificate), passwordCertificate,…

Thordax
- 1,673
- 4
- 28
- 54
7
votes
3 answers
The server mode SSL must use a certificate with the associated private key - during TLS handshake
I have a certificate someCert.cer. I imported it into my local certificates store using MMC utility. My C# application is able to access it using following code:
var store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
X509Certificate2…

Andrei
- 42,814
- 35
- 154
- 218
7
votes
2 answers
Can I use an X509Certificate2 within ASP.NET without using a certificate store?
I am trying to use an X509Certificate within an ASP.NET web service within the Rackspace Cloud. I have a feeling the certificate stores on the cloud nodes maybe causing problems. I also have a question related to this with the exception that I am…

Luke
- 6,195
- 11
- 57
- 85
6
votes
0 answers
"Received an unexpected EOF or 0 bytes from the transport stream" Azure WebService
I have the following issue:
I have built a webservice that is supposed to run as an Azure Webservice, which calls an external API retrieve some data. For the connection, the external company has provided me with a certificate which I succesfully…

dkoene
- 61
- 1
- 3
6
votes
2 answers
OpenSSL verify certificate from own CA
Hello all and thanks for your time reading this.
I need to verify certificates issued by my own CA, for which I have a
certificate. How can I do the equivalent to openssl's
openssl verify -CAfile
in Ruby code? The RDoc for OpenSSL is not very…

Bruno Antunes
- 2,241
- 4
- 21
- 35
6
votes
1 answer
How to create signed x509certificate with a private key using a self signed certificate
What I'd like to do is create a valid certificate to sign an electronic document. This requires a x509Certificate2 object with a private key. What I cant figure out is how to create a signed certificate with a private key, using a CA certificate…

user3357795
- 61
- 1
- 2
6
votes
1 answer
How to read Pkcs#7 certificate chain from file/stream in C#?
I have two certificates that I saved to disk. One is a certificate with private key that I exported as a .pfx file, the other one is a certificate that I saved including its certificate chain as a PKCS#7 file ("certchain.p7b").
In C# I can now load…

froh42
- 5,190
- 6
- 30
- 42