-
Notifications
You must be signed in to change notification settings - Fork 90
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
Lack of documentation in new recommended way of generating openssl certificates #76
Comments
cc @alexcernat |
About serial numbers: if you happen to use the deprecated pyOpenSSL backend, the serial numbers are between 1000 and 99999. If you use the (default) cryptography backend, you get ~20 bytes of randomness. Also, the random number generator used for the cryptography backend (os.urandom) has a much higher quality than the one used in the pyOpenSSL backend. |
indeed, the new default cryptography backend generates real random enough serial numbers, just tested it, thanks for the hint; I can forget about my signing bash script, as long as the generated certificate seems to be the same but I still don't get used to the new approach, it seems to me counter-intuitive (using the deprecated way to check a certificate you just define all required fields in a declarative way and execute later tasks only if the checking task failed); usually I try to change asap any deprecated issue into the new recommended way, but this time ... nope another idea for ownca: sometimes you want to select only a few of fields in CSR (when the CSR is generated elsewhere); for example: almost any CA will use only the CN from you CSR (for a standard DV certificate) ... no country, no organization, no locality I looked into the code (openssl_certificate module) and it is very possible to force the public key or maybe to select only some information from CSR ... any plans to implement this in the near or distant future ? |
If I understand you correctly, you want the That's one way to do it, I have worked around this issue by generating a test certificate from a given CSR, asserting on its contents and only then generating the real one. There are already a lot of parameters to |
this is a snippet from an ansible module written in bash which does the job: "$OPENSSL" x509 -req -sha256 -days 730 I know, many subshells and also the last line could be improved for openssl 1.1.x; some say it's a "ugly hack", but it works when you want to filter what data to put in the certificate and you don't have the private key to generate a new CSR (i.e. for a HP iLO system) like I said, the idea is to extract the public key from the CSR and to force generating a new independent certificate but with the extracted key as its public key of course it can be written as a command or shell module invocation, but IIRC the ansible philosophy is to use commands only as a last resort, if there isn't any other solution |
@MarkusTeufelberger I sometimes think we should split the openssl_certificate module into smaller modules (one for each provider). The number of options is already very high (even though it will get better when @MarkusTeufelberger @alexcernat I see that using |
@MarkusTeufelberger ping :) |
I'm semi-comfortable with the |
The community.crypto/plugins/modules/x509_certificate.py Lines 147 to 207 in 5f1efb6
|
As mentioned in #128, I think we need to come to a final conclusion here (or semi-final, as we can still add a new module later on). I personally never used the So basically to me, using What do you all think? |
Ok, it looks like nobody is interested enough in this anymore. I guess we'll continue without a replacement then... |
Well, my view hasn't changed, I'm still fine with The other issue (being able to ignore/overwrite values in a CSR) might still be a useful feature if you expect to handle CSRs coming from users with all kinds of garbage inside. I'm unsure if there's a way to kinda re-package a CSR (e.g. you get a weird one: create one with proper settings using Ansible instead, plop in the public key of the weird one and just don't sign it, then create a certificate from it ignoring the missing/invalid signature) that might be a bit more feasible than adding nearly all CSR fields to |
I think we should move this to a separate issue. Re-packing CSRs doesn't work, since you need the private key to sign them. I guess what you could do is create a new CSR with the fields you want (and another private key / signature), and then 'merge' these in the |
I created #320 for this aspect of this issue. |
Since 2.0.0 has been released without assertonly, and we have a new issue for the remaining content, I'm closing this. Thanks everyone! |
From @alexcernat on Jun 20, 2020 10:23
SUMMARY
I am using this code to generate self signed certificates:
First step is checking the actual certificate, and if it doesn't exists or is not valid (CA checks, CN checks, validity etc.), then the certificate is generated in step 2. The fact that I am using my own module to generate the certificate is irrelevant, the fact is that I need to run step 2 (generation) only if step 1 (checking) fails (or maybe if you have a better approach ...?)
From ansible 2.9 using openssl_certificate to check the validity of a certificate is deprecated (and set to be removed in 2.13 IIRC), the documentation suggest that I should use openssl_certificate_info to check different certificate parameters, but only an "assert" method is presented in the docs.
How can I translate that "when: verify_cert.failed" from step 2 in order to work with the new openssl_certificate_info module ? I think that such an example should be provided in the docs.
Also, as a feature request, I believe that a "serial" parameter should be included in the ownca module, or at least increase somehow the "randomness" of that serial number. Last time I've check the code, IIRC the serial was between 1 and 65535, which is not quite so "random".
ISSUE TYPE
COMPONENT NAME
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
ADDITIONAL INFORMATION
Copied from original issue: ansible/ansible#70193
The text was updated successfully, but these errors were encountered: