1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#!/usr/bin/env python3
# -*- mode: python -*-
# Copyright 2014-2016 Canonical Ltd.
# Copyright 2014 Cloudbase Solutions SRL.
# This software is licensed under the GNU Affero General Public License
# version 3 (see the file LICENSE).
"""Generates a x509 certificate used for WinRM service on Windows nodes."""
from maasserver.x509 import WinRMX509
import argparse
def make_argparser(description):
"""Create an `ArgumentParser` for this script."""
x509 = WinRMX509("winrm_client_cert")
parser = argparse.ArgumentParser(description=description)
parser.add_argument(
'--certname', '-c', default="winrm_client_cert",
help="x509 certificate name. (Default: winrm_client_cert)")
parser.add_argument(
'--store', '-s',
help="Destination folder for x509 cert. (Default: ~/.ssl)")
parser.add_argument(
'--upn', '-u',
help="UPN name for certificate. (Default: %s)" % x509.upn_name)
return parser
if __name__ == "__main__":
parser = make_argparser(__doc__)
args = parser.parse_args()
x509 = WinRMX509(args.certname, upn_name=args.upn, cert_dir=args.store)
x509.create_cert(print_cert=True)
|