3 # --sign hostname hostname hostname
4 # --list # lists all csrs needing to be signed
6 # --clean? not sure what it will do
13 import certmaster
.certs
14 import certmaster
.certmaster
18 from optparse
import OptionParser
20 def errorprint(stuff
):
21 print >> sys
.stderr
, stuff
25 usage
= 'certmaster-ca <option> [args]'
26 parser
= OptionParser(usage
=usage
)
28 parser
.add_option('-l', '--list', default
=False, action
="store_true",
29 help='list signing requests remaining')
30 parser
.add_option('-s', '--sign', default
=False, action
="store_true",
31 help='sign requests of hosts specified')
32 parser
.add_option('-c', '--clean', default
=False, action
="store_true",
33 help="clean out all certs or csrs for the hosts specified")
35 (opts
, args
) = parser
.parse_args()
38 if not opts
.list and not opts
.sign
and not opts
.clean
:
46 errorprint('Must be root to run certmaster-ca')
49 cm
= certmaster
.certmaster
.CertMaster()
51 (opts
, args
) = parseargs(args
)
55 hns
= cm
.get_csrs_waiting()
57 for hn
in cm
.get_csrs_waiting():
60 print 'No certificates to sign'
66 errorprint('Need hostnames to sign')
70 csrglob
= '%s/%s.csr' % (cm
.cfg
.csrroot
, hn
)
71 csrs
= glob
.glob(csrglob
)
73 errorprint('No match for %s to sign' % hn
)
77 certfile
= cm
.sign_this_csr(fn
)
78 print '%s signed - cert located at %s' % (fn
, certfile
)
83 errorprint('Need hostname(s) to clean up')
87 cm
.remove_this_cert(hn
)
91 if __name__
== "__main__":
92 sys
.exit(main(sys
.argv
[1:]))