x509证书的字符编码是什么?

huangapple go评论60阅读模式
英文:

What is the Character Encoding of x509 certificates?

问题

我正在实现一个SCEP服务器来分发客户端证书。根据协议,对于设备发送的GetCACert请求,响应头的内容类型应为application/x-x509-ca-cert

我的问题是,默认情况下,我的应用程序过滤器会将每个响应的字符编码设置为UTF-8,因此响应变为application/x-x509-ca-cert;charset=UTF-8。设备不喜欢这个字符编码部分,并拒绝了响应。

我怀疑设备可能会尝试将响应从UTF-8格式转换,所以我尝试将响应编码为UTF-8,但设备仍然不接受我的响应。

然后,我将Burp代理设置为设备,并从响应头中删除了charset=UTF-8部分,设备接受了响应。

经过一些搜索,我发现证书是用DER编码的,但是当我将DER作为字符编码时,Java会显示unknown-encoding,而且IANA字符编码中也没有官方字符集中的DER

我的问题是:“用于定义x509证书字符编码的官方字符集名称是什么?”

英文:

I'm implementing an SCEP server to distribute client certificates. According to the protocol, For the GetCACert request from device, the content-type of the response header should be application/x-x509-ca-cert.

My problem is that by default, the character encoding of every response is set as UTF-8 by my application's filter and so the response becomes application/x-x509-ca-cert;charset=UTF-8. The device doesn't like this character encoding part and rejects the response.

I suspected that the device might try to convert the response from UTF-8 format,and so I tried to encode my response to UTF-8, but the device still doesn't accept my response.

I then set burp proxy to device and removed the charset=UTF-8 part from response header and the device accepted the response.

Upon some googling, I found that the certificates are encoded with DER, but when I gave DER as the character encoding, java says unknown-encoding and also the IANA character encoding doesn't have DER in their official charsets.

My question is "what is the official charset name that can be used to define the character encoding of x509 certificate?".

答案1

得分: 4

证书是二进制的。它们没有字符编码,因为这些不是字符,而是纯八位字节。如果您尝试使用某种字符编码对这些非字符进行编码,将没有帮助。相反,您需要省略字符集属性。

英文:

The certificates are binary. They have no character encoding since these are no characters but plain octets (bytes). It will not help if you try to encode these non-characters with some character encoding. Instead you need to omit the charset attribute.

huangapple
  • 本文由 发表于 2020年9月10日 14:58:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/63824786.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定