Changeset 0c9393e for fedd


Ignore:
Timestamp:
Jul 12, 2011 11:32:05 AM (13 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master
Children:
771a277
Parents:
b3c4896
Message:

Acc --cn

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/cert_to_fedid.py

    rb3c4896 r0c9393e  
    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.