wood burning stoves 2.0*
The moose likes Security and the fly likes writing a digital certificate into a .cer file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Security
Bookmark "writing a digital certificate into a .cer file" Watch "writing a digital certificate into a .cer file" New topic

writing a digital certificate into a .cer file

hossein arabi

Joined: Jan 15, 2009
Posts: 20
hi everybody
I am stuck with writing a generated certificate into a file(.cer). I tried many ways but when I want to insert it into the browser it will give error that it is a invalid type.
I don know whether I should convert to any type like PKCS12 or not then write it to a file or how to correctly write it.
I will be really thankful if any one can show me a sample code.
Thank you

Carey Evans
Ranch Hand

Joined: May 27, 2008
Posts: 225

If you have an X509Certificate object, you can just write the bytes from its getEncoded() method to a FileOutputStream. Sometimes .cer files are base64-encoded PEM files, though, in which case you'd use something like Apache Commons Codec with the appropriate header and footer:
Don't get me started about those stupid light bulbs.
subject: writing a digital certificate into a .cer file
Similar Threads
problem calling a remote webservice [ Algo Error]
Generate a x.509 certificate in .cer filr
digital certificate
generated a PKI certificate in .cer file
How to get .cer and .p12 file of the same certificate.