Your IP : 216.73.216.52


Current Path : /opt/alt/python35/lib64/python3.5/test/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/test/__pycache__/make_ssl_certs.cpython-35.opt-1.pyc



��Yf��@@s=dZddlZddlZddlZddlZddlTdZejjejj	e
��Zdddd�Zd	Z
d
d�Zdd
�Zedkr9eje�ed�\ZZedd��Zeje�WdQRXedd��Zeje�WdQRXed�edddddddddg	�edddddddddg	�edd��!Zeje�eje�WdQRXedd��Zeje�WdQRXe�ed�\ZZed d��!Zeje�eje�WdQRXedd!�\ZZed"d��!Zeje�eje�WdQRXedd!�\ZZed#d��!Zeje�eje�WdQRXd$d%d&d'd(d)d*d+d,g	Zed-d.d/je��\ZZed0d��!Zeje�eje�WdQRXe�ed1�edd2ddd3d4d5g�dS)6zOMake the custom certificate and private key files used by test_ssl
and friends.�N)�*a
    [req]
    distinguished_name     = req_distinguished_name
    x509_extensions        = req_x509_extensions
    prompt                 = no

    [req_distinguished_name]
    C                      = XY
    L                      = Castle Anthrax
    O                      = Python Software Foundation
    CN                     = {hostname}

    [req_x509_extensions]
    subjectAltName         = @san

    [san]
    DNS.1 = {hostname}
    {extra_san}

    [dir_sect]
    C                      = XY
    L                      = Castle Anthrax
    O                      = Python Software Foundation
    CN                     = dirname example

    [princ_name]
    realm = EXP:0, GeneralString:KERBEROS.REALM
    principal_name = EXP:1, SEQUENCE:principal_seq

    [principal_seq]
    name_type = EXP:0, INTEGER:1
    name_string = EXP:1, SEQUENCE:principals

    [principals]
    princ1 = GeneralString:username

    [ ca ]
    default_ca      = CA_default

    [ CA_default ]
    dir = cadir
    database  = $dir/index.txt
    crlnumber = $dir/crl.txt
    default_md = sha1
    default_days = 3600
    default_crl_days = 3600
    certificate = pycacert.pem
    private_key = pycakey.pem
    serial    = $dir/serial
    RANDFILE  = $dir/.rand

    policy          = policy_match

    [ policy_match ]
    countryName             = match
    stateOrProvinceName     = optional
    organizationName        = match
    organizationalUnitName  = optional
    commonName              = supplied
    emailAddress            = optional

    [ policy_anything ]
    countryName   = optional
    stateOrProvinceName = optional
    localityName    = optional
    organizationName  = optional
    organizationalUnitName  = optional
    commonName    = supplied
    emailAddress    = optional


    [ v3_ca ]

    subjectKeyIdentifier=hash
    authorityKeyIdentifier=keyid:always,issuer
    basicConstraints = CA:true

    F�c&Cs�td|�g}x@td�D]2}tjdd��}|j|j�WdQRXq!W|\}}}zptjd|d|�}	t|d��}|j	|	�WdQRXdd	d
ddd
dd|d|g}
|rtjdd�� }|j|j�|j}WdQRX|
d|g7}
n|
dd|g7}
t
dg|
�|r�dd|d|dddddd|g}
t
dg|
�t|d��}|j�}WdQRXt|d��}|j�}
WdQRX||
fSWdx|D]}tj
|�q�WXdS)Nzcreating cert for �ZdeleteF�hostname�	extra_san�w�reqz-newz-days�3650z-nodesz-newkeyzrsa:1024z-keyoutz-configz-outz-x509�openssl�caz-outdir�cadirz-policyZpolicy_anythingz-batchz-infiles�r)�print�range�tempfile�NamedTemporaryFile�append�name�req_template�format�open�write�
check_call�read�os�remove)rZsignrZ	tempnames�i�fZreq_fileZ	cert_fileZkey_filer�argsZreqfile�cert�keyr�r!�8/opt/alt/python35/lib64/python3.5/test/make_ssl_certs.py�
make_cert_key[s>
r#rcCstjt�dS)N)�shutilZrmtree�	TMP_CADIRr!r!r!r"�	unmake_ca�sr&c5Cs�tjt�ttjjdd�d��}WdQRXttjjdd�d��}|jd�WdQRXttjjdd�d��}|jd�WdQRXtjd	��}|jt	j
d
ddd
��|j�tj���}dddddddddddd|jddg}t
dg|�dd|jddd d!d"td#dddd$ddd%|jg}t
dg|�dd|jd&dd'g}t
dg|�WdQRXWdQRXdS)(Nrz	index.txtza+zcrl.txtZ00zindex.txt.attrzw+zunique_subject = norrz
our-ca-serverrrrz-newz-daysr	z-extensionsZv3_caz-nodesz-newkeyzrsa:2048z-keyoutzpycakey.pemz-outz-subjzG/C=XY/L=Castle Anthrax/O=Python Software Foundation CA/CN=our-ca-serverr
rz-configz-create_serialzpycacert.pemz-batchz-outdirz-keyfilez	-selfsignz-infilesz-gencrlzrevocation.crl)r�mkdirr%r�path�joinrrrrr�flushrr)r�trr!r!r"�make_ca�s.
!!!
	r,�__main__Z	localhostzssl_cert.pemrzssl_key.pemz5password protecting ssl_key.pem in ssl_key.passwd.pemr
Zrsaz-inz-outzssl_key.passwd.pemz-des3z-passoutz
pass:somepasszkeycert.passwd.pemzkeycert.pemza+Zfakehostnamezkeycert2.pemTzkeycert3.pemzkeycert4.pemz0otherName.1 = 1.2.3.4;UTF8:some other identifierz/otherName.2 = 1.3.6.1.5.2.2;SEQUENCE:princ_namezemail.1 = user@example.orgzDNS.2 = www.example.orgzdirName.1 = dir_sectzURI.1 = https://www.python.org/zIP.1 = 127.0.0.1z
IP.2 = ::1zRID.1 = 1.2.3.4.5Zallsansr�
zallsans.pemzr

Please change the values in test_ssl.py, test_parse_cert function related to notAfter,notBefore and serialNumberZx509z-datesz-serialz-noout)�__doc__rr$�sysr�
subprocessrr(�abspath�dirname�__file__�herer#r%r&r,�__name__�chdirrr rrrrrrr)r!r!r!r"�<module>sn
O'

%%



	!