openssl/openssl

Windows command line mangles unicode

Open

#17,453 opened on Jan 10, 2022

View on GitHub
 (7 comments) (0 reactions) (0 assignees)C (11,262 forks)batch import
branch: 3.0branch: 3.1branch: 3.2branch: masterhelp wantedtriaged: bug

Repository metrics

Stars
 (30,157 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

My former colleague asked to bring up this issue. Unfortunately, I don't have Windows in my disposal now. Being build on windows using MinGW, both openssl 1.1.1m and 3.0.1 give an error

Command line:

openssl req -batch -newkey rsa -nodes -utf8 -keyout tmp.key -out tmp.req -subj /C=RU/L=Москва/CN=НеЗнаюЧТо

(the exact value of Russian letters don't really matter, it's important that they are Russian)

Error:

28120000:error:06800086:asn1 encoding routines:ASN1_mbstring_ncopy:invalid utf8string:crypto/asn1/a_mbstr.c:85:
req: Error adding subject name attribute "/L=╠юёътр"

The behavior does not change if we use chcp 866, both with command line invoked directly in cp866 or from a .bat file in UTF-8

Documentation says that, if -utf8 is specified, all strings should be encoded in UTF-8. Experiments show that it works well for the configuration file, but requires setting in cp866 via environment (for 3.0 series, 1.1.1 series is broken here).

Contributor guide