(cmdlineargs)
| 178 | shutil.rmtree(TMP_CADIR) |
| 179 | |
| 180 | def make_ca(cmdlineargs): |
| 181 | os.mkdir(TMP_CADIR) |
| 182 | with open(os.path.join('cadir','index.txt'),'a+') as f: |
| 183 | pass # empty file |
| 184 | with open(os.path.join('cadir','crl.txt'),'a+') as f: |
| 185 | f.write("00") |
| 186 | with open(os.path.join('cadir','index.txt.attr'),'w+') as f: |
| 187 | f.write('unique_subject = no') |
| 188 | # random start value for serial numbers |
| 189 | with open(os.path.join('cadir','serial'), 'w') as f: |
| 190 | f.write('CB2D80995A69525B\n') |
| 191 | |
| 192 | with tempfile.NamedTemporaryFile("w") as t: |
| 193 | req = req_template.format( |
| 194 | hostname='our-ca-server', |
| 195 | extra_san='', |
| 196 | startdate=startdate, |
| 197 | enddate=cmdlineargs.enddate, |
| 198 | days=cmdlineargs.days |
| 199 | ) |
| 200 | t.write(req) |
| 201 | t.flush() |
| 202 | with tempfile.NamedTemporaryFile() as f: |
| 203 | args = ['req', '-config', t.name, '-new', |
| 204 | '-nodes', |
| 205 | '-newkey', 'rsa:3072', |
| 206 | '-keyout', 'pycakey.pem', |
| 207 | '-out', f.name, |
| 208 | '-subj', '/C=XY/L=Castle Anthrax/O=Python Software Foundation CA/CN=our-ca-server'] |
| 209 | check_call(['openssl'] + args) |
| 210 | args = ['ca', '-config', t.name, |
| 211 | '-out', 'pycacert.pem', '-batch', '-outdir', TMP_CADIR, |
| 212 | '-keyfile', 'pycakey.pem', |
| 213 | '-selfsign', '-extensions', 'v3_ca', '-infiles', f.name ] |
| 214 | check_call(['openssl'] + args) |
| 215 | args = ['ca', '-config', t.name, '-gencrl', '-out', 'revocation.crl'] |
| 216 | check_call(['openssl'] + args) |
| 217 | |
| 218 | # capath hashes depend on subject! |
| 219 | check_call([ |
| 220 | 'openssl', 'x509', '-in', 'pycacert.pem', '-out', 'capath/ceff1710.0' |
| 221 | ]) |
| 222 | shutil.copy('capath/ceff1710.0', 'capath/b1930218.0') |
| 223 | |
| 224 | |
| 225 | def write_cert_reference(path): |
no test coverage detected
searching dependent graphs…