openssl: Unable to use -subj with Windows Git Bash
I am using Git for Windows with OpenSSL 1.1.1a
When I run openssl from the Git Bash, which emulates a POSIX environment, I am unable to pass -subj argument to openssl
Example output using "/C=GB/ST=London/L=London/O=Example Org/OU=Delivery/CN=example.org root CA"
$ openssl req -x509 -new -nodes -key ca.key -sha256 -days 3650 -out ca.pem \
-subj "/C=GB/ST=London/L=London/O=Example Org/OU=Delivery/CN=example.org root CA"
name is expected to be in the format /type0=value0/type1=value1/type2=... where characters may be escaped by \. This name is not in that format: 'C:/Program Files/Git/C=GB/ST=London/L=London/O=Example Org/OU=Delivery/CN=example.org root CA'
problems making Certificate Request
This might or might not be a problem with Git Bash. As you can see, it is trying to resolve the subject as it was a file inside C:\Program Files\Git
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 4
- Comments: 16 (3 by maintainers)
Commits related to this issue
- fix CI#24, for windows, ref openssl/openssl#8795 — committed to TheNorthMemory/easyalipay by TheNorthMemory 5 years ago
Another solution might be to use double slahes “//”
You might try setting the
MSYS_NO_PATHCONVenvironment variable to 1 before you start:https://github.com/git-for-windows/git/issues/577#issuecomment-166118846
2 Options:
Double slash will cause
req: Skipping unknown attribute "/C", workaround would be//C=GB/C=GB...In case helpful, I wanted to mention another solution which worked in my case, which was to simply drop to a
cmdshell inside of git bash and run the same command there. Since it’s a subprocess of git bash you still have openssl on the PATH and it seems to work. Once done, I was able to justexitout of the cmd shell and return to git bash.// Slash worked for me as well. Mentioned in in Matt Casswell’s reference and CoffeeFan. Thank you!
I found that a double forward slash did not work for me. Example:
-subj //CN=myCNValue/OU=myOuValue
However the following did:
-subj /“/CN=myCNValue/OU=myOuValue”
I am using Windows Git Bash.
The first option provided by @paulakande-couchbase, also works for me.
I encountered the same problem under Cygwin, and the solution was to use single quotes instead of double for the -subj.
Add / before /, the result like //
This is because the underlying libraries (coming from mingw) are trying to be smart and convert arguments that look like paths to actual paths.
As you can see, they are a little too smart some times.