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

Add an option to change the subject when signing a request. #439

Closed
wants to merge 2 commits into from

Conversation

mat813
Copy link

@mat813 mat813 commented Apr 13, 2021

Sometime, you get a request with "extra" information you would rather not have in the final certificate, this change allows changing the subject of the request when producing the certificate. This is done by adding an option to sign-req :

easyrsa sign-req client client-req subj '/O=Foo Inc./[email protected]'

@TinCanTech TinCanTech added initial-approval conflicts Conflicts with current labels Mar 29, 2022
@TinCanTech TinCanTech self-assigned this Jun 21, 2022
@mattbnz
Copy link

mattbnz commented Sep 6, 2022

Very useful patch thanks - looking forward to seeing this merged ASAP.

Note the help text in the usage() method on line 34 also needs updating to list the optional cmd-opts parameter.

@TinCanTech TinCanTech added this to the v3.1.3 - 13/10/2023 milestone Mar 2, 2023
@TinCanTech TinCanTech added Full-Approval Merge is imminent and removed initial-approval labels Mar 2, 2023
@TinCanTech TinCanTech removed this from the v3.1.3 milestone May 19, 2023
@TinCanTech TinCanTech removed the Full-Approval Merge is imminent label Aug 5, 2023
@TinCanTech
Copy link
Collaborator

TinCanTech commented Aug 6, 2023

Having to manually build an entire, syntactically correct, subject field, to overwrite the requested subject, seems to be a very prone to error.

Instead, the intent could be to overwrite the request subject field with values that are compliant to the signing CA. This is only relevant when the DN mode is set to org not cn_only.

The only other change which may be of value, is to change the commonName of the request AND have that commonName replace the output file name.

Example:

  • CSR with incorrect commonName=oof
  • Sign request file named oof.req with commonName=foo
  • Output to certificate named foo.crt not oof.crt [Undecided]

Centrally administering the commonName gives the advantage of controlling OpenVPN option --verify-x509-name foo name-prefix, by allowing the CA to dictate acceptable commonName values from remote request files. This allows the OpenVPN server to take full advantage of --verify-x509-name foo name-prefix, which is useful.

@TinCanTech
Copy link
Collaborator

@mat813 There is one problem with this PR.

When easyrsa sign-req shows the DN of the request to be signed, it shows the subject from the request, not the subject that will be inserted into the signed certificate.

I know this has been hanging around for far too long. I am happy to use the idea presented here but I would prefer to implement it differently.

My method allows the following (detailed here for discussion):

  • Request received with subject /CN=oof (DN mode cn_only).

  • In order of preference for DN mode org:

    1. Top priority: Use global options --req-*=value for all subject fields.
    2. Secondary: Use values from vars file for all fields except commonName, which would be explicitly set by --req-cn=foo
    3. Command: easyrsa --req-cn=foo sign-req client comply, comply forces use of -subj "$subject", where $subject is created from vars file values.
  • In DN mode cn_only:

  • Command: easyrsa --req-cn=foo sign-req client comply, comply forces use of --req-cn=foo only.

It sounds complicated but is fairly simple in practice.

The only outstanding problem is the file-name of the output certificate will still be named oof.crt. This is required to maintain compatibility with revoke and renew.

@TinCanTech
Copy link
Collaborator

Potentially superseded by #995

@TinCanTech
Copy link
Collaborator

TinCanTech commented Mar 8, 2024

Linking: #1087 #1089

@TinCanTech
Copy link
Collaborator

Superseded-by: #1111

Contribution attributed.

@TinCanTech TinCanTech closed this Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conflicts Conflicts with current Feature request feedback welcome Signature Signature Required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants