Skip to content
This repository was archived by the owner on Jul 16, 2026. It is now read-only.

Creating a self CA for SSL connections when testing - #3

Open
acien101 wants to merge 2 commits into
masterfrom
feat/SelfCA
Open

Creating a self CA for SSL connections when testing#3
acien101 wants to merge 2 commits into
masterfrom
feat/SelfCA

Conversation

@acien101

@acien101 acien101 commented Sep 9, 2019

Copy link
Copy Markdown
Member

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.

@m0wer m0wer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Amazing job! Thanks :-)

Comment thread tasks/main.yml

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

Copy link
Copy Markdown
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 thread tasks/main.yml
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
Copy Markdown
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.

Comment thread tasks/main.yml
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
Copy Markdown
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.

Comment thread tasks/main.yml
template:
src: san_template.ext.j2
dest: "/etc/letsencrypt/live/{{ domain }}/{{ domain }}.ext"
ignore_errors: yes

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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 subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants