Hi
I have a x.crt file which is used to sign certain contents and a signature file is generated x.sig the x.crt is having a Certificate part which contains a public key a content signature field etc. when i try to parse the x,crt and when i try to generate a x509 certificate its showing invalid DER format if try to extract public key alone also it throwing exception. I am not getting how to parse the x.crt as i am new to security part.
views:
51answers:
2May be your crt file is in PEM format? Open it in notepad and you will see.
Try openssl x509 -in cert.crt -inform PEM -out cert.pem -outform PEM in this case.
And what is your openssl command line?
It's really hard to give a useful answer from so little information. Where did the x.crt file come from (that is: what software produced it) and what are you trying to do with it?
Files with .crt extensions are usually digital certificates -- just certificates, not something "having a certificate part". Is your file actually a certificate, or is it something else?
As Donz suggests, if your file is a certificate then it may be in PEM format, in which you would need to convert it to binary DER format in order to parse it as DER.
You say that your file is used "to sign certain contents". You don't use a certificate to sign things, you use a certificate to verify signatures on things that are already signed. You need a private key to sign things. Perhaps what you have is some sort of container that contains a private key AND its corresponding certificate? It might be a PKCS#12 (PFX) file, for example, Is that possible?