How can I change key pair in xml format to PEM format in C#?

我怕爱的太早我们不能终老 提交于 2019-12-05 13:00:22

Remember that openssl is picky about PEM certificate formatting.

  1. The file must contain: -----BEGIN CERTIFICATE----- on a separate line (i.e. it must be terminated with a newline).
  2. Each line of "gibberish" must be 64 characters wide.
  3. The file must end with: -----END CERTIFICATE----- and also be terminated with a newline.
  4. Don't save the cert text with Word. It must be in ASCII.
  5. Don't mix DOS and UNIX style line terminations.

So in your case, it appears you are not line wrapping the "gibberish" at 64 characters, and your END tag is missing the newline.

For others out there not writing their own key pairs, here are a few steps you can take to normalize your certificate files on Linux:

  1. Run it through dos2unix: # dos2unix cert.pem
  2. Run it through fold: # fold -w 64 cert.pem

If you're on Windows, try downloading Cygwin, and you should be able to get these conversion tools.

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