Use X509Certv3 from string for WCF Service Endpoint?
I have exported a key pair (public and private key) into a single cert from a Win2k8 server. I then used OpenSSL to convert it to a pem:
openssl pkcs12 -in cert.pfx -out cert.pem -nodes
I then put the contents of the .pem in a MSSQL table, Varchar(max) column type.
Using .NET Framework 4.0 only.
I get the cert like this:
var bytes = Encoding.UTF8.GetBytes("certstringfromdatabase");
var cert = new X5开发者_如何学C09Certificate(bytes, passwordstring);
I get an error "Cryptographic Exception was unhandled Cannot find the specified object."
Am I converting to byte[] incorrectly? This is for a custom WCF service with TCP binding, I am trying to use the certificate for SSL without touching the internal store (because this will be one day migrated to Azure worker role I can't use a cert store or filesystem).
Thanks for all ideas.
There is much more involved than what I was doing.
Check out http://www.codeproject.com/KB/security/CertificatesToDBandBack.aspx and that's that.
精彩评论