示例#1
0
def read_private_key(path_key, path_pem, path_crypt, csdpass, new_pass):
    from sh import openssl
    try:
        output = openssl.pkcs8('-inform',
                               'DER',
                               '-in',
                               path_key,
                               '-out',
                               path_pem,
                               '-passin',
                               'stdin',
                               _in=csdpass)
    except:
        return False
    if output.exit_code != 0:
        return False
    try:
        output = openssl.rsa('-in',
                             path_pem,
                             '-des3',
                             '-out',
                             path_crypt,
                             '-passout',
                             'stdin',
                             _in=new_pass)
    except:
        return False
    return True
示例#2
0
def check_key_cert_match(path_key,path_cer,key_pass):
    from sh import openssl
    try:
        out_cer=openssl.x509('-inform','DER','-noout','-modulus','-in',path_cer)
        out_key=openssl.rsa('-noout','-modulus','-in',path_key,'-passin','stdin',_in=key_pass)
    except:
        return False
    if out_cer.split("=")[1]!=out_key.split("=")[1]:
        return False
    return True
示例#3
0
def read_private_key(path_key,path_pem,path_crypt,csdpass,new_pass):
    from sh import openssl
    try:
    	output=openssl.pkcs8('-inform','DER','-in',path_key,'-out',path_pem,'-passin','stdin',_in=csdpass)
    except:
        return False
    if output.exit_code!=0:
        return False
    try:
        output=openssl.rsa('-in',path_pem,'-des3','-out',path_crypt,'-passout','stdin',_in=new_pass)
    except:
        return False
    return True
示例#4
0
def check_key_cert_match(path_key, path_cer, key_pass):
    from sh import openssl
    try:
        out_cer = openssl.x509('-inform', 'DER', '-noout', '-modulus', '-in',
                               path_cer)
        out_key = openssl.rsa('-noout',
                              '-modulus',
                              '-in',
                              path_key,
                              '-passin',
                              'stdin',
                              _in=key_pass)
    except:
        return False
    if out_cer.split("=")[1] != out_key.split("=")[1]:
        return False
    return True