Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- X509Certificate2 clientCertificate =
- this.Request.HttpContext.Connection.ClientCertificate;
- X509Chain x509Chain = new X509Chain(){ ChainPolicy = new
- X509ChainPolicy({...}};
- x509Chain.Build(clientCertificate))
- var elements = x509Chain.ChainElements.Cast<X509ChainElement>()
- // in elements variable I expect to have more than one item but I don't have
- Pkcs12Store store = new Pkcs12Store();
- X509CertificateEntry[] chain = new X509CertificateEntry[5];
- X509Certificate cert1 = certParser.ReadCertificate(new
- MemoryStream(Encoding.UTF8.GetBytes(certString1)));
- X509CertificateEntry certificateEntry1 = new X509CertificateEntry(cert1);
- chain[0] = certificateEntry1;
- // I adds all certs in order from user cert to root one (self signed)
- store.SetKeyEntry(csr.GetCertificationRequestInfo().Subject.ToString(), new
- AsymmetricKeyEntry(key.Private), chain);
- using (var filestream = new FileStream("./full.cert.pfx"), FileMode.Create,
- FileAccess.ReadWrite)){
- store.Save(filestream, "".ToCharArray(), new SecureRandom());
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement