2
votes

I have a CSR in PEM format that I need to convert to .DER. Using OpenSSL, this is how I do it.

openssl req -inform pem -outform der -in customer.csr -out customer.der

Looking for .NET APIs or third party libraries that can do this?

Update: This app is a Azure cloud service with multiple instances.

Thx, Ash

1
You can always just use OpenSSL by starting a new Process with those command line parameters from your application. Is this something you have considered? I can post code sample if you like.Mike Marynowski
Thanks Mike. I forgot to mention that it's an ASP.NET app that I need to use this in. Would prefer something with APIs to keep the implementation clean.SoftwareWeaver
You can still use that solution in ASP.NET. There won't be anything built into .NET that can do that for sure, perhaps a third party library somewhere, but I've done similar things from ASP.NET applications that run ffmpeg processes to manipulate video files and video streams. I think the code is very readable and it works very well.Mike Marynowski
Have you looked at BouncyCastle?bloudraak

1 Answers

0
votes

Here is a lib, that a fellow wrote to do that and a few other tricks.

In .NET, the two widely spread formats for key exchange, PEM and DER are not supported, which limits the usability of the class when working with different kinds of public key APIs.

Workaround: Leverage Microsoft Crypto API (CAPI), which provides support for opening and converting a variety of different public/private key file formats. Here I would like to demonstrate how this can be achieved by means of simple extension methods to the RSACryptoServiceProvider class.

See: http://www.christian-etter.de/?p=771