@@ -20,7 +20,7 @@ make_certs() {
2020 mkdir " tmp/"
2121
2222# OpenSSL settings
23- CONF=" ${script_path} /openssltest .cnf"
23+ CONF=" ${script_path} /openssl_intermediate .cnf"
2424 TEMP_LD_LIBRARY_PATH=$LD_LIBRARY_PATH
2525 if test -n " $1 "
2626 then
@@ -44,12 +44,33 @@ make_certs() {
4444 TZ=GMT faketime -f ' @2017-01-01 00:00:00' /bin/bash -c '
4545 script_path=$(pwd)
4646 OPENSSL=openssl
47- CONF="${script_path}/openssltest .cnf"
47+ CONF="${script_path}/openssl_root .cnf"
4848 $OPENSSL req -config $CONF -new -x509 -days 3600 -key demoCA/CA.key -out tmp/CACert.pem \
49- -subj "/C=PL/O=osslsigncode/OU=Root CA /CN=CA/[email protected] " \ 49+ -subj "/C=PL/O=osslsigncode/OU=Certification Authority /CN=Root CA " \
5050 2>> "makecerts.log" 1>&2'
5151 test_result $?
5252
53+ printf " \nGenerate intermediate CA certificate\n" >> " makecerts.log"
54+ $OPENSSL genrsa -out demoCA/intermediate.key \
55+ 2>> " makecerts.log" 1>&2
56+ TZ=GMT faketime -f ' @2017-01-01 00:00:00' /bin/bash -c '
57+ script_path=$(pwd)
58+ OPENSSL=openssl
59+ CONF="${script_path}/openssl_intermediate.cnf"
60+ $OPENSSL req -config $CONF -new -key demoCA/intermediate.key -out demoCA/intermediate.csr \
61+ -subj "/C=PL/O=osslsigncode/OU=Certification Authority/CN=Intermediate CA" \
62+ 2>> "makecerts.log" 1>&2'
63+ test_result $?
64+ TZ=GMT faketime -f ' @2017-01-01 00:00:00' /bin/bash -c '
65+ script_path=$(pwd)
66+ OPENSSL=openssl
67+ CONF="${script_path}/openssl_root.cnf"
68+ $OPENSSL ca -config $CONF -batch -in demoCA/intermediate.csr -out demoCA/intermediate.cer \
69+ 2>> "makecerts.log" 1>&2'
70+ test_result $?
71+ $OPENSSL x509 -in demoCA/intermediate.cer -out tmp/intermediate.pem \
72+ 2>> " makecerts.log" 1>&2
73+
5374 printf " \nGenerate private RSA encrypted key\n" >> " makecerts.log"
5475 $OPENSSL genrsa -des3 -out demoCA/private.key -passout pass:$password \
5576 2>> " makecerts.log" 1>&2
@@ -63,40 +84,48 @@ make_certs() {
6384
6485 printf " \nGenerate a certificate to revoke\n" >> " makecerts.log"
6586 $OPENSSL req -config $CONF -new -key demoCA/private.key -passin pass:$password -out demoCA/revoked.csr \
66- -subj " /C=PL/O=osslsigncode/OU=CA /CN=revoked /emailAddress=revoked @example.com" \
87+ -subj " /C=PL/O=osslsigncode/OU=CSP /CN=Revoked /emailAddress=osslsigncode @example.com" \
6788 2>> " makecerts.log" 1>&2
6889 $OPENSSL ca -config $CONF -batch -in demoCA/revoked.csr -out demoCA/revoked.cer \
6990 2>> " makecerts.log" 1>&2
7091 $OPENSSL x509 -in demoCA/revoked.cer -out tmp/revoked.pem \
7192 2>> " makecerts.log" 1>&2
7293
7394 printf " \nRevoke above certificate\n" >> " makecerts.log"
74- $OPENSSL ca -config $CONF -revoke demoCA/1000 .pem \
95+ $OPENSSL ca -config $CONF -revoke demoCA/1001 .pem \
7596 2>> " makecerts.log" 1>&2
7697
98+ printf " \nAttach intermediate certificate to revoked certificate\n" >> " makecerts.log"
99+ cat tmp/intermediate.pem >> tmp/revoked.pem
100+
77101 printf " \nGenerate CRL file\n" >> " makecerts.log"
78102 TZ=GMT faketime -f ' @2019-01-01 00:00:00' /bin/bash -c '
79103 script_path=$(pwd)
80104 OPENSSL=openssl
81- CONF="${script_path}/openssltest .cnf"
105+ CONF="${script_path}/openssl_intermediate .cnf"
82106 $OPENSSL ca -config $CONF -gencrl -crldays 8766 -out tmp/CACertCRL.pem \
83107 2>> "makecerts.log" 1>&2'
84108
109+ printf " \nConvert revoked certificate to SPC format\n" >> " makecerts.log"
110+ $OPENSSL crl2pkcs7 -in tmp/CACertCRL.pem -certfile tmp/revoked.pem -outform DER -out tmp/revoked.spc \
111+ 2>> " makecerts.log" 1>&2
112+ test_result $?
113+
85114 printf " \nGenerate CSP Cross-Certificate\n" >> " makecerts.log"
86115 $OPENSSL genrsa -out demoCA/cross.key \
87116 2>> " makecerts.log" 1>&2
88117 TZ=GMT faketime -f ' @2018-01-01 00:00:00' /bin/bash -c '
89118 script_path=$(pwd)
90119 OPENSSL=openssl
91- CONF="${script_path}/openssltest .cnf"
92- $OPENSSL req -config $CONF -new -x509 -days 900 -key demoCA/cross.key -out tmp/crosscert.pem \
93- -subj "/C=PL/O=osslsigncode/OU=CSP/CN=crosscert/emailAddress=CA @example.com" \
120+ CONF="${script_path}/openssl_intermediate .cnf"
121+ $OPENSSL req -config $CONF -new -x509 -days 900 -key demoCA/cross.key -out tmp/crosscert.pem \
122+ -subj "/C=PL/O=osslsigncode/OU=CSP/CN=crosscert/emailAddress=osslsigncode @example.com" \
94123 2>> "makecerts.log" 1>&2'
95124 test_result $?
96125
97126 printf " \nGenerate code signing certificate\n" >> " makecerts.log"
98127 $OPENSSL req -config $CONF -new -key demoCA/private.key -passin pass:$password -out demoCA/cert.csr \
99- -subj
" /C=PL/ST=Mazovia Province/L=Warsaw/O=osslsigncode/OU=CA /CN=localhost /[email protected] " \
128+ -subj
" /C=PL/ST=Mazovia Province/L=Warsaw/O=osslsigncode/OU=CSP /CN=Certificate /[email protected] " \
100129 2>> " makecerts.log" 1>&2
101130 test_result $?
102131 $OPENSSL ca -config $CONF -batch -in demoCA/cert.csr -out demoCA/cert.cer \
@@ -111,11 +140,19 @@ make_certs() {
111140 2>> " makecerts.log" 1>&2
112141 test_result $?
113142
143+ printf " \nConvert the key to PVK format\n" >> " makecerts.log"
144+ $OPENSSL rsa -in tmp/key.pem -outform PVK -out tmp/key.pvk -pvk-none \
145+ 2>> " makecerts.log" 1>&2
146+ test_result $?
147+
114148 printf " \nConvert the certificate to DER format\n" >> " makecerts.log"
115149 $OPENSSL x509 -in tmp/cert.pem -outform DER -out tmp/cert.der \
116150 2>> " makecerts.log" 1>&2
117151 test_result $?
118152
153+ printf " \nAttach intermediate certificate to code signing certificate\n" >> " makecerts.log"
154+ cat tmp/intermediate.pem >> tmp/cert.pem
155+
119156 printf " \nConvert the certificate to SPC format\n" >> " makecerts.log"
120157 $OPENSSL crl2pkcs7 -nocrl -certfile tmp/cert.pem -outform DER -out tmp/cert.spc \
121158 2>> " makecerts.log" 1>&2
@@ -128,7 +165,7 @@ make_certs() {
128165
129166 printf " \nGenerate expired certificate\n" >> " makecerts.log"
130167 $OPENSSL req -config $CONF -new -key demoCA/private.key -passin pass:$password -out demoCA/expired.csr \
131- -subj " /C=PL/ST=Mazovia Province/L=Warsaw/O=osslsigncode/OU=CA /CN=expired /emailAddress=expired @example.com" \
168+ -subj " /C=PL/ST=Mazovia Province/L=Warsaw/O=osslsigncode/OU=CSP /CN=Expired /emailAddress=osslsigncode @example.com" \
132169 2>> " makecerts.log" 1>&2
133170 test_result $?
134171 $OPENSSL ca -config $CONF -enddate " 190101000000Z" -batch -in demoCA/expired.csr -out demoCA/expired.cer \
@@ -138,10 +175,14 @@ make_certs() {
138175 2>> " makecerts.log" 1>&2
139176 test_result $?
140177
178+ printf " \nAttach intermediate certificate to expired certificate\n" >> " makecerts.log"
179+ cat tmp/intermediate.pem >> tmp/expired.pem
180+
141181# copy new files
142- if test -s tmp/CACert.pem -a -s tmp/crosscert.pem -a -s tmp/expired.pem -a -s tmp/cert.pem \
143- -a -s tmp/CACertCRL.pem -a -s tmp/revoked.pem -a -s tmp/key.pem -a -s tmp/keyp.pem \
144- -a -s tmp/key.der -a -s tmp/cert.der -a -s tmp/cert.spc -a -s tmp/cert.p12
182+ if test -s tmp/intermediate.pem -a -s tmp/CACert.pem -a -s tmp/CACertCRL.pem \
183+ -a -s tmp/key.pem -a -s tmp/keyp.pem -a -s tmp/key.der -a -s tmp/key.pvk \
184+ -a -s tmp/cert.pem -a -s tmp/cert.p12 -a -s tmp/cert.der -a -s tmp/cert.spc \
185+ -a -s tmp/crosscert.pem -a -s tmp/expired.pem -a -s tmp/revoked.pem -a -s tmp/revoked.spc
145186 then
146187 cp tmp/* ./
147188 printf " %s\n" " keys & certificates successfully generated"
0 commit comments