I'm running a simple PKI web application in Php that uses OpenSSL shell commands and stores information in a text database. I have to deal with non-ASCII input characters (eg. German) but when a new cert is created, the fields turn into

[...] /C=DE/ST=H\xC3\xA4mburg/L=H\xC3\xA4mburg/O=\xC3\x9FBCD/OU=\xC3\xA4BC/ [...]

I've added

utf8                = yes
string_mask         = utf8only
name_opt            = multiline,-esc_msb,utf8

to the OpenSSL config files, and the certs are created using

openssl req -utf8 [...]
openssl ca -utf8 [...]

The program writes out temporary config files used to request and create the user cert. I've checked and the fields in the user config file are fine, as well as in the CA's. The problem appears when OpenSSL creates the certificates. The database and the certs contain these codes instead of the correct characters.

I also tried to convert the database file to UTF-8 using iconv but the file remains in US-ASCII format. This approach changes what file --mime-encoding outputs to utf-8, but OpenSSL continues to write new entries the same way as before.

I'll also mention I'm sending the utf-8 header and setting AddDefaultCharset utf-8 in virtualhosts. The locale is set to de_DE.utf8 in the code and on the server.

What am I missing? Any help is appreciated.

  • Have you an solution?
    – raiserle
    Oct 15, 2017 at 16:19
  • I'll just point out that as long as utf8 = yes/-utf8 is set, and the local LANG variable is correct in the terminal. The certificate will be created with the correct formatting. The output of openssl x509 -noout -text however, does not handle interpretation of UTF8 characters outside of A-Z, there for certain chars will become \C3\A4 for instance, but viewed in a browser they'll look perfectly fine.
    – Torxed
    Jan 13, 2021 at 14:29

1 Answer 1


I was struggling with this for days aswell, finally got it working.

-utf8 on the commandline and utf8 = yes in the config seems a bit redundant.

I used -utf8 -nameopt multiline,utf8 on the commandline, i did'nt escape anything in the config file (I tried several versions of that but none worked) which says UTF-8 Unicode text when i run file <configfile>.

My locale and cli are configured to use utf-8 input and output, config is similar to:

prompt = no
distinguished_name = subject

C = DE
ST = myutf8state
L = myutf8locality
O = myutf8organization
OU = myutf8organizational unit
CN = my.common.name

I found these 2 questions on stackoverflow to be of help:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.