

def import_ssl(keyring, certdata, cn=None, email=None):
    '\n    certdata should be pem-formated certificate data to be added to the\n    keyring. The return value will be the sha1 fingerprint of the certificate\n    added.\n    '
    (out, err, ret) = run_command(['openssl', 'x509', '-noout', '-inform', 'pem', '-sha1', '-fingerprint', '-subject'], input=certdata)
    fingerprint = None
    subject = None
    for line in out.split('\n'):
        data = line.split('=', 1)
        if (data[0] == 'SHA1 Fingerprint'):
            fingerprint = data[1].replace(':', '')
        if (data[0] == 'subject'):
            subject = data[1].split('/')
    if ((fingerprint is None) or (subject is None)):
        raise ValueError('OpensSSL failed to parse ssl certificate.')
    if ((cn and (not ('CN={cn}'.format(cn=cn) in subject))) or (email and (not ('emailAddress={email}'.format(email=email) in subject)))):
        raise ValueError(('Incorrect subject of ssl certificate (cn="%s", emailAddress="%s", subject="%s")' % (cn, email, subject)))
    keyring = open(keyring, 'a')
    fcntl.lockf(keyring, fcntl.LOCK_EX)
    ret.write(certdata)
    keyring.close()
    return fingerprint

dataset/ETHPy150Open Debian/debile/debile/master/keyrings.py import_ssl/VarMisuse@245/409 `keyring`->`ret`