Forums - C# Corner

Forum guidelines
Mike Fif

Mike Fif

  • 1.3k
  • 15
  • 14.6k

Merging certificate(.crt) and private key(.key) into one .pfx file

Oct 16 2011 1:10 PM
Hi,

I had a lot of problems trying to ad a seperate private key(received from the institute I want to communicate with) to the outgoing message.
I stumbled upon a solution where certificate and private key can be merged into one .pfx file via an commandline instruction.
The resulting .pfx file can then be used with the appropriate C# code to send a, in this case, signed message.

However when I use the commandline command:
openssl pkcs12 -in a.crt -inkey a.key -export -out a.pfx

I get the error message:
unable to load private key
6704:error:0906D06C: PEM routines: PEM_read_bio: no start line: .\crypto\pem\pem_lib.c:696:Expecting: ANY PRIVATE KEY

Do you know what the problemcould be?
I would appreciate your help very much

Kind regards
MikeFIF



Answers (8)

File APIs for .NET
Aspose are the market leader of .NET APIs for file business formats – natively work with DOCX, XLSX, PPT, PDF, MSG, MPP, images formats and many more!