Changeset 2d601b7 for fedd


Ignore:
Timestamp:
Jul 12, 2011 11:30:45 AM (13 years ago)
Author:
Ted Faber <faber@…>
Branches:
compt_changes, info-ops, master
Children:
62e8e03
Parents:
816daef
Message:

Add an option to specify a CN directly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/cert_to_fedid.py

    r816daef r2d601b7  
    2121        self.add_option('--cert', dest='cert',
    2222                help='Cretificate to copy subject from')
     23        self.add_option('--cn', dest='cn', default=None,
     24                help='Set the CN directly')
    2325        self.add_option('--openssl', dest='openssl',
    2426                help='Path to openssl command', default='/usr/bin/openssl')
     
    4244
    4345try:
    44     c = X509.load_cert(opts.cert)
    45     subj = c.get_subject().as_text()
    46     if subj.startswith('/'): i = 1
    47     else: i = 0
    48     subj = '/' + re.sub('/', '\/', subj[i:])
     46    if opts.cn is not None:
     47        subj = '/CN=' + opts.cn
     48        if len(subj) > 64: subj = subj[0:63]
     49    else:
     50        c = X509.load_cert(opts.cert)
     51        subj = c.get_subject().as_text()
     52        if subj.startswith('/'): i = 1
     53        else: i = 0
     54        subj = '/' + re.sub('/', '\/', subj[i:])
    4955
    5056    tf, tn = tempfile.mkstemp(suffix=".pem")
Note: See TracChangeset for help on using the changeset viewer.