blob: 9dfdd2ed575c161fe158e4b4072534cdf7f04329 [file] [log] [blame]
Jean-Paul Calderone897bc252008-02-18 20:50:23 -05001"""
2Create certificates and private keys for the 'simple' example.
3"""
4
5from OpenSSL import crypto
6from certgen import * # yes yes, I know, I'm lazy
7cakey = createKeyPair(TYPE_RSA, 1024)
8careq = createCertRequest(cakey, CN='Certificate Authority')
9cacert = createCertificate(careq, (careq, cakey), 0, (0, 60*60*24*365*5)) # five years
10open('simple/CA.pkey', 'w').write(crypto.dump_privatekey(crypto.FILETYPE_PEM, cakey))
11open('simple/CA.cert', 'w').write(crypto.dump_certificate(crypto.FILETYPE_PEM, cacert))
12for (fname, cname) in [('client', 'Simple Client'), ('server', 'Simple Server')]:
13 pkey = createKeyPair(TYPE_RSA, 1024)
14 req = createCertRequest(pkey, CN=cname)
15 cert = createCertificate(req, (cacert, cakey), 1, (0, 60*60*24*365*5)) # five years
16 open('simple/%s.pkey' % (fname,), 'w').write(crypto.dump_privatekey(crypto.FILETYPE_PEM, pkey))
17 open('simple/%s.cert' % (fname,), 'w').write(crypto.dump_certificate(crypto.FILETYPE_PEM, cert))