Convert X.509 certificate from hex form to .cer format

♀尐吖头ヾ 提交于 2019-12-31 03:04:30

问题


How to convert X.509 certificate from a hex-dump form to .CER format? Additionally, should be blank space separators removed from hex dump first? Thanks.


回答1:


You could use ASN.1 editor. It has a data converter that will convert HEX to PEM format of data. the source is also available so if you need to use it in code you can look how it is done.

Or you could use certutil.exe using command

certutil -decodehex c:\cert.hex c:\cert.cer



回答2:


Normally .cer can either be binary encoded - DER - or it can be DER that has an "ASCII armor", called PEM.

If you want to create DER you probably only have to decode the hexadecimals. In that case you obviously need to disregard any whitespace within the hexadecimals (as well as any other spurious data that may be present).

If you want to have PEM it is required in addition to base 64 encode the result and add a header and footer text. Or you can use an existing library that does this of course.



来源:https://stackoverflow.com/questions/22584568/convert-x-509-certificate-from-hex-form-to-cer-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!