certificatejavax509encodingscep

What is the Character Encoding of x509 certificates?


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?".


Solution

  • 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.