Debian Codegraph @

ansible_collections/community/windows/tests/integration/targets/win_psmodule/files/setup_certs.sh

raw
1 #!/usr/bin/env bash
2
3 # Generate key used for CA cert
4 openssl genrsa -aes256 -out ca.key -passout pass:password 2048
5
6 # Generate CA certificate
7 openssl req -new -x509 -days 365 -key ca.key -out ca.pem -subj "/CN=Ansible Root" -passin pass:password
8
9 # Generate key used for signing cert
10 openssl genrsa -aes256 -out sign.key -passout pass:password 2048
11
12 # Generate CSR for signing cert that includes CodeSiging extension
13 openssl req -new -key sign.key -out sign.csr -subj "/CN=Ansible Sign" -config openssl.conf -reqexts req_sign -passin pass:password
14
15 # Generate signing certificate
16 openssl x509 -req -in sign.csr -CA ca.pem -CAkey ca.key -CAcreateserial -out sign.pem -days 365 -extfile openssl.conf -extensions req_sign -passin pass:password
17
18 # Create pfx that includes signing cert and cert with the pass 'password'
19 pfx_args=()
20 if [ "${1}" == "-use-legacy" ]; then
21 pfx_args=("-certpbe" "PBE-SHA1-3DES" "-keypbe" "PBE-SHA1-3DES" "-macalg" "SHA1")
22 fi
23 openssl pkcs12 -export -out sign.pfx -inkey sign.key -in sign.pem -passin pass:password -passout pass:password "${pfx_args[@]}"