#!/usr/bin/python """ Application to request a cert from a certmaster. Takes no arguments, uses /etc/certmaster/minion.conf Copyright 2008, Red Hat, Inc Michael DeHaan This software may be freely redistributed under the terms of the GNU general public license. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. """ import distutils.sysconfig import optparse import sys import xmlrpclib from certmaster import requester if __name__ == "__main__": parser = optparse.OptionParser() parser.add_option('--hostname', action="store", dest="hostname", metavar="NAME", help='hostname to use as the CN for the certificate') parser.add_option('--ca', action="store", dest="ca", default='', metavar="CA", help='certificate authority used to sign the certificate') (opts, args) = parser.parse_args() try: requester.request_cert(hostname=opts.hostname, ca_name=opts.ca) except xmlrpclib.Fault as f: print >> sys.stderr, "error: %s" % str(f.faultString) except Exception as e: print >> sys.stderr, "error: %s" % str(e) sys.exit(1)