EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Converting an OpenSSL X509 Certificate to TElX509Certificate in C#

Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.
#26122
Posted: 08/14/2013 06:38:16
by PogoMips (Basic support level)
Joined: 08/14/2013
Posts: 2

Hi,

I was wondering if it's possible to convert an OpenSSL X509 certificate to an TElX509Certificate. I tried the following options:

Code
MyCertificate.LoadFromBuffer(MySSLCertificate.DER);


which results in a NullReferenceException

Secondly it's possible in OpenSSL to get a PEM String representation of the certificate. It looks like this:

Code
-----BEGIN CERTIFICATE-----
MIIEQDCCAyigAwIBAgIQbBgM4ilnp19XTofH5/6BRzANBgkqhkiG9w0BAQUFADCB
kDELMAkGA1UEBhMCREUxGzAZBgNVBAgTEkJhZGVuLVd1ZXJ0dGVtYmVyZzERMA8G
...
-----END CERTIFICATE-----


This method seems to do what I want, but I can't figure out how to create the byte array needed.

Code
MyCertificate.LoadFromBufferPEM(buf, 0, buf.Length, "")  


Any ideas on this?
#26123
Posted: 08/14/2013 06:56:52
by Ken Ivanov (Team)

Hello,

Thank you for getting in touch with us.

TElX509Certificate can load certificate in variety of formats. In particular, LoadFromBuffer() should have worked fine for you - please re-check that you are passing the correct array to it and that the TElX509Certificate object reference is valid.

Quote
This method seems to do what I want, but I can't figure out how to create the byte array needed.

You can use System.Text.Encoding.UTF8.GetBytes(PEMString) to convert the PEM string to a byte array.
#26124
Posted: 08/14/2013 07:52:25
by PogoMips (Basic support level)
Joined: 08/14/2013
Posts: 2

Thanks for your help, that worked.
Now I just need to find a way to copy the private key as well, since this doesn't seem to work automatically.
#26127
Posted: 08/14/2013 08:42:16
by Ken Ivanov (Team)

The private key (if not in the certificate PEM) should be loaded separately with LoadKeyFromBuffer() or LoadKeyFromBufferPEM() methods.

Reply

Statistics

Topic viewed 1169 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!