mirror of
https://github.com/trailofbits/algo.git
synced 2025-09-03 10:33:13 +02:00
openssl commands folded
This commit is contained in:
parent
dd1af76c34
commit
50a961c6d2
1 changed files with 51 additions and 15 deletions
|
@ -37,9 +37,15 @@
|
||||||
dest: "configs/{{ IP_subject_alt_name }}/pki/openssl.cnf"
|
dest: "configs/{{ IP_subject_alt_name }}/pki/openssl.cnf"
|
||||||
|
|
||||||
- name: Build the CA pair
|
- name: Build the CA pair
|
||||||
shell: |
|
shell: >
|
||||||
openssl ecparam -name prime256v1 -out ecparams/prime256v1.pem &&
|
openssl ecparam -name prime256v1 -out ecparams/prime256v1.pem &&
|
||||||
openssl req -utf8 -new -newkey {{ algo_params | default('ec:ecparams/prime256v1.pem') }} -config openssl.cnf -keyout private/cakey.pem -out cacert.pem -x509 -days 3650 -batch -passout pass:"{{ easyrsa_CA_password }}" &&
|
openssl req -utf8 -new
|
||||||
|
-newkey {{ algo_params | default('ec:ecparams/prime256v1.pem') }}
|
||||||
|
-config openssl.cnf
|
||||||
|
-keyout private/cakey.pem
|
||||||
|
-out cacert.pem -x509 -days 3650
|
||||||
|
-batch
|
||||||
|
-passout pass:"{{ easyrsa_CA_password }}" &&
|
||||||
touch {{ IP_subject_alt_name }}_ca_generated
|
touch {{ IP_subject_alt_name }}_ca_generated
|
||||||
args:
|
args:
|
||||||
chdir: "configs/{{ IP_subject_alt_name }}/pki/"
|
chdir: "configs/{{ IP_subject_alt_name }}/pki/"
|
||||||
|
@ -60,9 +66,20 @@
|
||||||
creates: serial_generated
|
creates: serial_generated
|
||||||
|
|
||||||
- name: Build the server pair
|
- name: Build the server pair
|
||||||
shell: |
|
shell: >
|
||||||
openssl req -utf8 -new -newkey {{ algo_params | default('ec:ecparams/prime256v1.pem') }} -config openssl.cnf -keyout private/{{ IP_subject_alt_name }}.key -out reqs/{{ IP_subject_alt_name }}.req -nodes -passin pass:"{{ easyrsa_CA_password }}" -subj "/CN={{ IP_subject_alt_name }}" -batch &&
|
openssl req -utf8 -new
|
||||||
openssl ca -utf8 -in reqs/{{ IP_subject_alt_name }}.req -out certs/{{ IP_subject_alt_name }}.crt -config openssl.cnf -days 3650 -batch -passin pass:"{{ easyrsa_CA_password }}" -subj "/CN={{ IP_subject_alt_name }}" &&
|
-newkey {{ algo_params | default('ec:ecparams/prime256v1.pem') }}
|
||||||
|
-config openssl.cnf
|
||||||
|
-keyout private/{{ IP_subject_alt_name }}.key
|
||||||
|
-out reqs/{{ IP_subject_alt_name }}.req -nodes
|
||||||
|
-passin pass:"{{ easyrsa_CA_password }}"
|
||||||
|
-subj "/CN={{ IP_subject_alt_name }}" -batch &&
|
||||||
|
openssl ca -utf8
|
||||||
|
-in reqs/{{ IP_subject_alt_name }}.req
|
||||||
|
-out certs/{{ IP_subject_alt_name }}.crt
|
||||||
|
-config openssl.cnf -days 3650 -batch
|
||||||
|
-passin pass:"{{ easyrsa_CA_password }}"
|
||||||
|
-subj "/CN={{ IP_subject_alt_name }}" &&
|
||||||
touch certs/{{ IP_subject_alt_name }}_crt_generated
|
touch certs/{{ IP_subject_alt_name }}_crt_generated
|
||||||
args:
|
args:
|
||||||
chdir: "configs/{{ IP_subject_alt_name }}/pki/"
|
chdir: "configs/{{ IP_subject_alt_name }}/pki/"
|
||||||
|
@ -71,9 +88,20 @@
|
||||||
subjectAltName: "DNS:{{ IP_subject_alt_name }},IP:{{ IP_subject_alt_name }}"
|
subjectAltName: "DNS:{{ IP_subject_alt_name }},IP:{{ IP_subject_alt_name }}"
|
||||||
|
|
||||||
- name: Build the client's pair
|
- name: Build the client's pair
|
||||||
shell: |
|
shell: >
|
||||||
openssl req -utf8 -new -newkey {{ algo_params | default('ec:ecparams/prime256v1.pem') }} -config openssl.cnf -keyout private/{{ item }}.key -out reqs/{{ item }}.req -nodes -passin pass:"{{ easyrsa_CA_password }}" -subj "/CN={{ item }}" -batch &&
|
openssl req -utf8 -new
|
||||||
openssl ca -utf8 -in reqs/{{ item }}.req -out certs/{{ item }}.crt -config openssl.cnf -days 3650 -batch -passin pass:"{{ easyrsa_CA_password }}" -subj "/CN={{ item }}" &&
|
-newkey {{ algo_params | default('ec:ecparams/prime256v1.pem') }}
|
||||||
|
-config openssl.cnf
|
||||||
|
-keyout private/{{ item }}.key
|
||||||
|
-out reqs/{{ item }}.req -nodes
|
||||||
|
-passin pass:"{{ easyrsa_CA_password }}"
|
||||||
|
-subj "/CN={{ item }}" -batch &&
|
||||||
|
openssl ca -utf8
|
||||||
|
-in reqs/{{ item }}.req
|
||||||
|
-out certs/{{ item }}.crt
|
||||||
|
-config openssl.cnf -days 3650 -batch
|
||||||
|
-passin pass:"{{ easyrsa_CA_password }}"
|
||||||
|
-subj "/CN={{ item }}" &&
|
||||||
touch certs/{{ item }}_crt_generated
|
touch certs/{{ item }}_crt_generated
|
||||||
args:
|
args:
|
||||||
chdir: "configs/{{ IP_subject_alt_name }}/pki/"
|
chdir: "configs/{{ IP_subject_alt_name }}/pki/"
|
||||||
|
@ -84,7 +112,8 @@
|
||||||
|
|
||||||
- name: Build the client's p12
|
- name: Build the client's p12
|
||||||
shell: >
|
shell: >
|
||||||
openssl pkcs12 -in certs/{{ item }}.crt
|
openssl pkcs12
|
||||||
|
-in certs/{{ item }}.crt
|
||||||
-inkey private/{{ item }}.key
|
-inkey private/{{ item }}.key
|
||||||
-export
|
-export
|
||||||
-name {{ item }}
|
-name {{ item }}
|
||||||
|
@ -104,7 +133,7 @@
|
||||||
- "{{ users }}"
|
- "{{ users }}"
|
||||||
|
|
||||||
- name: Get active users
|
- name: Get active users
|
||||||
shell: |
|
shell: >
|
||||||
grep ^V index.txt |
|
grep ^V index.txt |
|
||||||
grep -v "{{ IP_subject_alt_name }}" |
|
grep -v "{{ IP_subject_alt_name }}" |
|
||||||
awk '{print $5}' |
|
awk '{print $5}' |
|
||||||
|
@ -114,12 +143,19 @@
|
||||||
register: valid_certs
|
register: valid_certs
|
||||||
|
|
||||||
- name: Revoke non-existing users
|
- name: Revoke non-existing users
|
||||||
shell: |
|
shell: >
|
||||||
openssl ca -config openssl.cnf -passin pass:"{{ easyrsa_CA_password }}" -revoke certs/{{ item }}.crt &&
|
openssl ca
|
||||||
openssl ca -gencrl -config openssl.cnf -passin pass:"{{ easyrsa_CA_password }}" -revoke certs/{{ item }}.crt -out crl/{{ item }}.crt
|
-config openssl.cnf
|
||||||
touch crl/{{ item }}_revoked
|
-passin pass:"{{ easyrsa_CA_password }}"
|
||||||
|
-revoke certs/{{ item }}.crt &&
|
||||||
|
openssl ca -gencrl
|
||||||
|
-config openssl.cnf
|
||||||
|
-passin pass:"{{ easyrsa_CA_password }}"
|
||||||
|
-revoke certs/{{ item }}.crt
|
||||||
|
-out crl/{{ item }}.crt
|
||||||
|
touch crl/{{ item }}_revoked
|
||||||
args:
|
args:
|
||||||
chdir: "configs/{{ IP_subject_alt_name }}/pki/"
|
chdir: configs/{{ IP_subject_alt_name }}/pki/
|
||||||
creates: crl/{{ item }}_revoked
|
creates: crl/{{ item }}_revoked
|
||||||
environment:
|
environment:
|
||||||
subjectAltName: "DNS:{{ item }}"
|
subjectAltName: "DNS:{{ item }}"
|
||||||
|
|
Loading…
Add table
Reference in a new issue