1
# Copyright 2005-2008 Divmod, Inc. See LICENSE file for details
5
from twisted.python import usage
6
from twisted.internet.ssl import KeyPair
9
class Options(usage.Options):
11
["country", "C", "US", None],
12
["state", "s", "New York", None],
13
["city", "c", "New York", None],
14
["organization", "o", "Divmod LLC", None],
15
["unit", "u", "Security", None],
16
["hostname", "h", "divmod.com", None],
17
["email", "e", "support@divmod.org", None],
19
["filename", "f", "server.pem", "Name of the file to which to write the PEM."],
20
["serial-number", "S", 1, None],
29
def createSSLCertificate(opts):
31
for x, y in (('country','C'),
34
('organization', 'O'),
37
('email','emailAddress')):
39
serialNumber = int(opts['serial-number'])
40
ssc = KeyPair.generate().selfSignedCert(serialNumber, **sslopt)
41
file(opts['filename'], 'w').write(ssc.dumpPEM())
43
print 'Wrote SSL certificate:'
51
Create a private key and a certificate and write them to a file.
59
except usage.UsageError, e:
60
raise SystemExit(str(e))
62
return createSSLCertificate(o)