allow p12 creation without cacert; timelimit openssl exec #57
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
openssl
fails for some reason.When trying to create a self-signed certificate , and bundling the private key and the certificate into a PKCS12 file, it will fail as follows, because there is no CA used for signing. This is not an error, and it's perfectly legal to create self-signed PKCS12 bundle.
There is no indication why it failed. It's actually the exec of
openssl
that fails due to bad arguments (see below)If we create a CA first, then use that CA, the PKCS12 certificate generation works, and it embeds the CA certificate into the PKCS12 file too. But this is not the desired result, since we only want a self-signed certificate and private key in the PKCS12 file, and there is no CA for a self-signed certificate.
An example below, showing how we can create and use the CA certificate:
The root cause is how the command line is built, it always provides the CA file as an option to
openssl
even if it's an empty string (not set on thetg
command line) and this empty string for the CA file causes theopenssl
command to fail.This code change also includes a timeout for the execution of
openssl
to limit it to 60 seconds max before it will be killed and fail. This bounds the execution environment to prevent hangs while the code is waiting foropenssl
to finish.After this PR is merged the PKCS12 self-signed certificate can now be created:
Motivation and Context
Fixes an issue that prevents you from creating a self-signed PKCS12 file.
How Has This Been Tested?
openssl pkcs12 info
Types of changes
Checklist