Skip to content

Conversation

@acien101
Copy link
Member

@acien101 acien101 commented Sep 9, 2019

Creating a self CA for signing certificates when testing. Otherwise, chrome dont accept connections to localhost, because certificate is not valid.

Using this doc and this one

To establish SSL connection, add the rootCA.pem to your system certificates, located on the host machine on /etc/letsencrypt/live/CA/rootCA.pem.

Copy link
Member

@m0wer m0wer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing job! Thanks :-)


- name: Create self-signed root certificate (CA), if testing.
command: >
openssl req -x509 -new -nodes -subj '/CN=lili' -days 30
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

¿Why lili? ¿Couldn't it be anarres instad?

Comment on lines +89 to +96
-newkey rsa:4096 -sha256 -keyout /etc/letsencrypt/live/CA/rootCA.key
-out /etc/letsencrypt/live/CA/rootCA.pem
args:
creates: /etc/letsencrypt/live/CA/rootCA.pem
ignore_errors: yes
when:
- testing is defined
- letsencrypt_cert.stat.exists == False
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the condition letsencrypt_cert.stat.exists == False we're only checking that the cert for {{ domain }} exists so if the CA was already created this command is going to overwrite it. Even if it doesn't the condition must be related to the file it creates. You could use

args:
    creates: /path/to/file

in the command task so it's only executed if the rootCA.key doesn't already exist.

openssl req -x509 -nodes -subj '/CN={{ domain }}' -days 30
-newkey rsa:4096 -sha256 -keyout /etc/letsencrypt/live/{{ domain }}/privkey.pem
-out /etc/letsencrypt/live/{{ domain }}/cert.pem
openssl req -new -nodes -subj '/CN=lili' -days 30 \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here with the CN, maybe using the {{ domain }} is a better idea.

template:
src: san_template.ext.j2
dest: "/etc/letsencrypt/live/{{ domain }}/{{ domain }}.ext"
ignore_errors: yes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

¿Why?

Comment on lines +1 to +7
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names

[alt_names]
DNS.1 = {{ domain }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

¿Can you explain this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping @acien101.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants