de4d0474e73921f11a9df8cab2fdbe055269c95f
[certmaster.git] / scripts / certmaster-request
1 #!/usr/bin/python
2
3 """
4 Application to request a cert from a certmaster.
5 Takes no arguments, uses /etc/certmaster/minion.conf
6
7 Copyright 2008, Red Hat, Inc
8 Michael DeHaan <mdehaan@redhat.com>
9
10 This software may be freely redistributed under the terms of the GNU
11 general public license.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 """
17
18 import distutils.sysconfig
19 import optparse
20 import sys
21
22 from certmaster import requester
23
24 if __name__ == "__main__":
25 parser = optparse.OptionParser()
26
27 parser.add_option('--hostname', action="store", dest="hostname",
28 metavar="NAME",
29 help='hostname to use as the CN for the certificate')
30
31 parser.add_option('--ca', action="store", dest="ca", default='',
32 metavar="CA",
33 help='certificate authority used to sign the certificate')
34
35 (opts, args) = parser.parse_args()
36
37 try:
38 requester.request_cert(hostname=opts.hostname, ca_name=opts.ca)
39 except Exception as e:
40 print >> sys.stderr, "error: %s" % str(e)