Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build-ca: Replace password temp-file method with file-descriptors #955

Merged
merged 3 commits into from
May 8, 2023

Conversation

TinCanTech
Copy link
Collaborator

@TinCanTech TinCanTech commented May 6, 2023

Until now, EasyRSA has used temp-files to store the CA password and passed those temp-files to SSL to build a CA keypair, when building a CA manually, with a password.

From now, EasyRSA will use an internal variable to contain the CA password and pass the value of that variable via file-descriptors to SSL, when building a CA keypair.

This file-descriptor method is only used when building a CA with a password manually, when the user enters the password via keyboard. All other build-ca methods remain unchanged.

Also, move keypair temp-files to output files or error out.

Also, minor improvements to comments and verbose messages.

Original-concept: #950

Until now, EasyRSA has used temp-files to store the CA password and
passed those temp-files to SSL to build a CA keypair, when building
a CA manually, with a password.

From now, EasyRSA will use an internal variable to contain the CA
password and pass the value of that variable via file-descriptors
to SSL, when building a CA keypair.

This file-descriptor method is only used when building a CA with a
password manually, when the user enters the password via keyboard.
All other build-ca methods remain unchanged.

Also, move keypair temp-files to output files or error out.

Also, minor improvements to comments and verbose messages.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
@TinCanTech TinCanTech self-assigned this May 6, 2023
@TinCanTech TinCanTech added enhancement Major Changes Changes between Major 3.X version numbers - X is Major ChangeLog Item version 3.1.3 labels May 6, 2023
@TinCanTech TinCanTech added this to the v3.1.3 - 13/10/2023 milestone May 6, 2023
@TinCanTech
Copy link
Collaborator Author

TinCanTech commented May 6, 2023

The unit-test does not test this code, so I have manually tested it on Linux and Windows.. and LibreSSL..

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
@TinCanTech
Copy link
Collaborator Author

TinCanTech commented May 6, 2023

I cannot help thinking that this method needs to allow fallback to temp-files, even though it has passed all tests.

Perhaps, this would be better as an option, such as:

easyrsa --pw-via-fd build-ca

Otherwise, it is an extreme change.

This allows a fallback to use temp-files for CA password, in the event
that file-descriptor method fails.

Signed-off-by: Richard T Bonhomme <tincantech@protonmail.com>
@TinCanTech TinCanTech merged commit 0719f54 into OpenVPN:master May 8, 2023
@Wolf1098
Copy link

Wolf1098 commented May 20, 2023

good thoughts on the extreme change -- using the default powershell of windows terminal to run the bat

EasyRSA Shell

./easyrsa build-ca

  • Using Easy-RSA configuration:
    C:/Users/User/Downloads/EasyRSA-3.1.3/pki/vars

  • Using SSL: openssl OpenSSL 3.0.8 7 Feb 2023 (Library: OpenSSL 3.0.8 7 Feb 2023)

Enter New CA Key Passphrase:
Passphrase must be at least 4 characters!

Enter New CA Key Passphrase:
Passphrase must be at least 4 characters!

Enter New CA Key Passphrase:

Confirm New CA Key Passphrase:
Using configuration from C:/Users/User/Downloads/EasyRSA-3.1.3/pki/188860fa/temp.5.1
Invalid password argument, starting with "fd:"
Error getting password

Easy-RSA error:

easyrsa_openssl - Command has failed:

  • openssl genpkey -config C:/Users/User/Downloads/EasyRSA-3.1.3/pki/188860fa/temp.5.1 -algorithm rsa -pkeyopt rsa_keygen_bits:2048 -out C:/Users/User/Downloads/EasyRSA-3.1.3/pki/188860fa/temp.1.1 -aes256 -pass fd:3

EasyRSA Version Information
Version: 3.1.3
Generated: Fri May 19 07:56:29 CDT 2023
SSL Lib: OpenSSL 3.0.8 7 Feb 2023 (Library: OpenSSL 3.0.8 7 Feb 2023)
Git Commit: 3fa9cd8
Source Repo: https://github.com/OpenVPN/easy-rsa
Host: 3.1.3 | win | @(#)MIRBSD KSH R39-w32-beta14 $Date: 2013/06/28 21:28:57 $ |


EasyRSA Shell

./easyrsa --ca-via-tf build-ca

  • Using Easy-RSA configuration:
    C:/Users/User/Downloads/EasyRSA-3.1.3/pki/vars

  • Using SSL: openssl OpenSSL 3.0.8 7 Feb 2023 (Library: OpenSSL 3.0.8 7 Feb 2023)

Enter New CA Key Passphrase:
Passphrase must be at least 4 characters!

Enter New CA Key Passphrase:

Confirm New CA Key Passphrase:
Using configuration from C:/Users/User/Downloads/EasyRSA-3.1.3/pki/402bbdff/temp.7.1

Notice

CA creation complete. Your new CA certificate is at:

  • C:/Users/User/Downloads/EasyRSA-3.1.3/pki/ca.crt

@Wolf1098
Copy link

may want to make some documentation somewhere of the --ca-via-tf workaround other than searching past issues and finding this discussion

@TinCanTech
Copy link
Collaborator Author

@Wolf1098 Thanks for testing and reporting this.

The openssl error Invalid password argument, starting with "fd:" .. I can confirm, also happens in my test.

:embarrassed and annoyed emoji:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ChangeLog Item enhancement Full-Approval Merge is imminent Major Changes Changes between Major 3.X version numbers - X is Major version 3.1.3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants