certs.py 783 B

12345678910111213141516171819202122232425262728
  1. from cert_gen import gen_cakey,build_name,build_csr,build_servercert,build_rootca,output_cert,output_key_encrypted,build_crl
  2. def gencerts(c,st,l,o,ou,cn,crldp,passphrase):
  3. ## Build Root CA
  4. casubject = caissuer = build_name(c,st,l,o,ou,u'Root CA')
  5. cakey = gen_cakey()
  6. cacert = build_rootca(cakey,casubject,caissuer,36500)
  7. ## Build CSR
  8. csrkey = gen_cakey()
  9. csrsubject = build_name(c,st,l,o,ou,cn)
  10. csrcert = build_csr(csrkey,csrsubject,cn)
  11. ## Build Server Cert
  12. servercert = build_servercert(cakey,cacert,csrcert,cn,crldp,36500)
  13. crlcert = build_crl(cakey,caissuer,36500)
  14. return csrsubject,output_cert(cacert),output_key_encrypted(cakey,passphrase),output_key_encrypted(csrkey,passphrase),output_cert(servercert),output_cert(csrcert),output_cert(crlcert)