Current File : //usr/local/apps/python3/lib/python3.11/test/__pycache__/make_ssl_certs.cpython-311.pyc
�

�Ke�$��D	�dZddlZddlZddlZddlZddlTdZdZdZej	�
ej	�e����Z
		d4d�ZdZd
�Zd�Zd�Zedk�r9eje
��edd���\ZZedd��5Ze�e��ddd��n#1swxYwYedd��5Ze�e��ddd��n#1swxYwYed��egd���egd���edd��5Ze�e��e�e��ddd��n#1swxYwYedd��5Ze�e��ddd��n#1swxYwYe��edd���\ZZedd��5Ze�e��e�e��ddd��n#1swxYwYedd� ��\ZZed!d��5Ze�e��e�e��ddd��n#1swxYwYedd� ��\ZZed"d��5Ze�e��e�e��ddd��n#1swxYwYed#dd$�%��\ZZed&d��5Ze�e��e�e��ddd��n#1swxYwYgd'�Zed(dd)�e���*��\ZZed+d��5Ze�e��e�e��ddd��n#1swxYwYgd,�Zed-dd)�e���*��\ZZed.d��5Ze�e��e�e��ddd��n#1swxYwYed/dd0�1��\ZZed2d��5Ze�e��e�e��ddd��n#1swxYwYe��ed3��ed��ed!��dSdS)5zOMake the custom certificate and private key files used by test_ssl
and friends.�N)�*�20180829142316Z�20371028142316Za�

    [ default ]
    base_url               = http://testca.pythontest.net/testca

    [req]
    distinguished_name     = req_distinguished_name
    prompt                 = no

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

    [req_x509_extensions_nosan]

    [req_x509_extensions_simple]
    subjectAltName         = @san

    [req_x509_extensions_full]
    subjectAltName         = @san
    keyUsage               = critical,keyEncipherment,digitalSignature
    extendedKeyUsage       = serverAuth,clientAuth
    basicConstraints       = critical,CA:false
    subjectKeyIdentifier   = hash
    authorityKeyIdentifier = keyid:always,issuer:always
    authorityInfoAccess    = @issuer_ocsp_info
    crlDistributionPoints  = @crl_info

    [ issuer_ocsp_info ]
    caIssuers;URI.0        = $base_url/pycacert.cer
    OCSP;URI.0             = $base_url/ocsp/

    [ crl_info ]
    URI.0                  = $base_url/revocation.crl

    [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 = sha256
    startdate = {startdate}
    default_startdate = {startdate}
    enddate = {enddate}
    default_enddate = {enddate}
    default_days = 7000
    default_crl_days = 7000
    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��req_x509_extensions_full�rsa:3072c�h�td|z��g}td��D]I}tjd���5}|�|j��ddd��n#1swxYwY�J|\}}	}
	t�||tt���}t|d��5}|�|��ddd��n#1swxYwYddd	d
dd|d
|
d|d|g
}|rVtjd���5}|�|j��|j}
ddd��n#1swxYwY|d|
gz
}n|dd|	gz
}tdg|z��|r#dd|d|d|	dddddd|
g}tdg|z��t|	d��5}|�
��}ddd��n#1swxYwYt|
d��5}|�
��}ddd��n#1swxYwY||f|D]}tj|���S#|D]}tj|���wxYw)Nzcreating cert for �F)�delete��hostname�	extra_san�	startdate�enddate�w�req�-new�-nodesz-days�7000�-newkey�-keyout�-extensions�-config�-outz-x509�openssl�ca�-outdir�cadirz-policy�policy_anything�-batch�-infiles�r)�print�range�tempfile�NamedTemporaryFile�append�name�req_template�formatrr�open�write�
check_call�read�os�remove)r
�signr�ext�key�	tempnames�i�f�req_file�	cert_file�key_filer�args�reqfile�certr(s                �=/usr/local/apps/python3/lib/python3.11/test/make_ssl_certs.py�
make_cert_keyr>ws���	�
��
)�*�*�*��I�
�1�X�X�%�%��
�
(��
6�
6�
6�	%�!����Q�V�$�$�$�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%�	%����	%�	%�	%�	%��$-�!�H�i��+��!�!�����	"�
�
���(�C�
 �
 �	�A�
�G�G�C�L�L�L�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��v�x��&��3�	�8��s��8�%���	2��,�E�:�:�:�
!�a�� � ���(�(�(��&��
!�
!�
!�
!�
!�
!�
!�
!�
!�
!�
!����
!�
!�
!�
!�
�V�W�&�&�D�D�
�W�f�i�1�1�D��I�;��%�&�&�&��
	+���8��s��	��7��,��*�g��D�
�	�{�T�)�*�*�*��)�S�
!�
!�	�Q��6�6�8�8�D�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	�
�(�C�
 �
 �	�A��&�&�(�(�C�	�	�	�	�	�	�	�	�	�	�	����	�	�	�	��S�y��	�	�D��I�d�O�O�O�O�	��I�	�	�D��I�d�O�O�O�O�	���s��A"�"A&	�)A&	�58H�-C�H�C�H�C�)H�"D.�"H�.D2�2H�5D2�6AH�F2�&H�2F6�6H�9F6�:H�
G.�"H�.G2�2H�5G2�6H�H1rc�8�tjt��dS)N)�shutil�rmtree�	TMP_CADIR��r=�	unmake_carE�s��
�M�)�����rDc��tjt��ttj�dd��d��5}	ddd��n#1swxYwYttj�dd��d��5}|�d��ddd��n#1swxYwYttj�dd��d��5}|�d��ddd��n#1swxYwYttj�dd	��d
��5}|�d��ddd��n#1swxYwYtjd
��5}t�
dd
tt���}|�|��|�
��tj��5}dd|jddddddd|jddg
}tdg|z��dd|jddddtddd d!d"d#|jg}tdg|z��dd|jd$dd%g}tdg|z��ddd��n#1swxYwYddd��n#1swxYwYtgd&���t!jd'd(��dS))Nrz	index.txt�a+zcrl.txt�00zindex.txt.attrzw+zunique_subject = no�serialrzCB2D80995A69525B
z
our-ca-serverrrrrrrrrrzpycakey.pemrz-subjzG/C=XY/L=Castle Anthrax/O=Python Software Foundation CA/CN=our-ca-serverrr�pycacert.pemr rz-keyfilez	-selfsignr�v3_car!z-gencrlzrevocation.crl)r�x509�-inrJr�capath/ceff1710.0rNzcapath/b1930218.0)r/�mkdirrBr+�path�joinr,r%r&r)r*rr�flushr(r-r@�copy)r6�trr:s    r=�make_carU�s���H�Y����	
�b�g�l�l�7�;�/�/��	5�	5�
���
�
�
�
�
�
�
�
�
�
�
����
�
�
�
�	
�b�g�l�l�7�9�-�-�d�	3�	3��q�	����
�
�
�������������������	
�b�g�l�l�7�#3�4�4�T�	:�	:�'�a�	���%�&�&�&�'�'�'�'�'�'�'�'�'�'�'����'�'�'�'�
�b�g�l�l�7�8�,�,�c�	2�	2�&�a�	���$�%�%�%�&�&�&�&�&�&�&�&�&�&�&����&�&�&�&�
�	$�S�	)�	)�+�Q��!�!�$����	"�
�
��	
�������	���	�	�	�
�
(�
*�
*�	+�a��9�a�f�f���z��}��A�F��f�h�D�
�	�{�T�)�*�*�*��)�Q�V��N�H�i���
�����Q�V�N�D�
�	�{�T�)�*�*�*��)�Q�V�Y��@P�Q�D��	�{�T�)�*�*�*�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+�	+����	+�	+�	+�	+�+�+�+�+�+�+�+�+�+�+�+����+�+�+�+�4��������K�#�%8�9�9�9�9�9s��A�A�A�B1�1B5�8B5�*D�D�D�E'�'E+�.E+�A%J�+BI7�+J�7I;	�;J�>I;	�?J�J�Jc�\�ddl}tj|�|����dS)Nr)�_ssl�pprint�_test_decode_cert)rPrWs  r=�
print_certrZ�s/���K�K�K�
�M�$�(�(��.�.�/�/�/�/�/rD�__main__�	localhost�req_x509_extensions_simple)r2zssl_cert.pemr�ssl_key.pemz5password protecting ssl_key.pem in ssl_key.passwd.pem)	r�pkeyrMr^rzssl_key.passwd.pem�-aes256�-passout�
pass:somepass)	rr_rMr^r�keycert.passwd.pemr`rarbzkeycert.pemrcrG�fakehostnamezkeycert2.pemT)r1zkeycert3.pemzkeycert4.pemz
localhost-ecczparam:secp384r1.pem)r1r3zkeycertecc.pem)	z0otherName.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.5�allsans�
)r1rzallsans.pem)z'DNS.2 = xn--knig-5qa.idn.pythontest.netz6DNS.3 = xn--knigsgsschen-lcb0w.idna2003.pythontest.netz6DNS.4 = xn--knigsgchen-b4a3dun.idna2008.pythontest.netz,DNS.5 = xn--nxasmq6b.idna2003.pythontest.netz,DNS.6 = xn--nxasmm1c.idna2008.pythontest.net�idnsanszidnsans.pem�nosan�req_x509_extensions_nosan)r1r2z	nosan.pemz>update Lib/test/test_ssl.py and Lib/test/test_asyncio/utils.py)Frrr)�__doc__r/rXr@r%�
subprocessrrr)rP�abspath�dirname�__file__�herer>rBrErUrZ�__name__�chdirr<r3r+r6r,r#r-rrQrCrDr=�<module>rrs����
�	�	�	�
�
�
�
�
�
�
�
����������	�
��e��N
�w���r�w���x�0�0�1�1��35�6@�3�3�3�3�j
�	����):�):�):�X0�0�0�
�z����B�H�T�N�N�N��
�k�/K�L�L�L�I�D�#�	
��n�c�	"�	"��a�	����
�
�
�������������������	
��m�S�	!�	!��Q�	�������������������������	�E�
A�B�B�B��J�v�v�v�w�w�w��J�v�v�v�w�w�w�	
��m�S�	!�	!��Q�	�������	����
�
�
�������������������
��"�D�	)�	)��Q�	����
�
�
��������������������G�I�I�I��
�n�2N�O�O�O�I�D�#�	
��n�c�	"�	"��a�	�������	����
�
�
��������������������
�k��5�5�5�I�D�#�	
��n�c�	"�	"��a�	�������	����
�
�
��������������������
�n�4�8�8�8�I�D�#�	
��n�c�	"�	"��a�	�������	����
�
�
��������������������
��d�(=����I�D�#�
����	$�	$���	�������	����
�
�
����������������������I��
�i�d�d�i�i�	�>R�>R�S�S�S�I�D�#�	
��m�S�	!�	!��Q�	�������	����
�
�
�������������������	�	�	�I��
�i�d�d�i�i�	�>R�>R�S�S�S�I�D�#�	
��m�S�	!�	!��Q�	�������	����
�
�
��������������������
�g�D�6Q�R�R�R�I�D�#�	
��k�3�	�	��1�	�������	����
�
�
��������������������I�K�K�K�	�E�
J�K�K�K��J�}�����J�~������m�s��B5�5B9�<B9�C.�.C2�5C2�*+E!�!E%�(E%�8F�F�!F�+H�H�	H�)+I � I$�'I$�+J>�>K�K�&+L�L!�$L!�+N�N�N�+P	�	P
�P
�1+Q(�(Q,�/Q,