x509certificate - Can the same x509 certificate have two different PEM encoding?
问题描述
It was my belief that the PEM encoding were unique.
But I have seen that the same certificate can have two different pem versions. Or at least, I have two PEM certificates that contain the same information (serial number, CA issuer etc...) so they should be the same.
Can the same certificate have two different PEM encoding?
解决方案
There are no two different encoding versions for same set of certificate data.
Presentation in PEM may be slightly different. I mean, PEM may include or missing PEM header and footer, Base64-encoded payload may or may not have line breaks after 64 characters, but it doesn't affect the Base64-encoded value, because line breaks are not part of encoding and ignored by Base64 encoder/decoder. The raw value unchanged for single certificate.
Update:
Exact PEM format is defined in RFC 1421, but it is not always followed and I see different presentations which can be called PEM as well (even though they don't strictly follow RFC). For example, I saw such as:
-----BEGIN XYX-----
<Base64 string split in 64 chars per line>
<Base64 string split in 64 chars per line>
<Base64 string split in 64 chars per line>
-----END XYZ-----
or
-----BEGIN XYX-----
<Long Base64 string split in single line (without line breaks>
-----END XYZ-----
or even this:
-----BEGIN XYX-----<Long Base64 string split in single line (without line breaks>-----END XYZ-----
or variations of these formats. Only first example is legit PEM format, while the rest are not-compliant, but can be called PEM, because they have PEM header and footer, and Base64-encoded payload.
推荐阅读
- flutter - 在 Listview 中使用具有共享偏好的收藏按钮
- powershell - powershell 从 cmd 运行以启动程序并退出。程序将继续运行,但 powershell 应该退出
- reactjs - babel-plugin-named-asset-import 是做什么的
- pdf - 在 pdf 层中嵌入 pdf 内容
- javascript - Lodash过滤器使用多个属性的对象数组
- c# - 如何拆分此数据表?
- python - Python如何正确使用Pexpect?
- python - 如何使 (style =“display: none;”) 元素在 python selenium 中可见
- r - 使用风险比和置信区间的森林图
- mysql - 通过命令行将 HTML(带有内联样式)插入 MySQL