
    ;e$                     D	   d Z ddlZddlZddlZddlZddlT dZdZdZej	        
                    ej	                            e                    Z	 	 d4dZdZd Zd Zd Zedk    r9 ej        e            edd          \  ZZ edd          5 Ze                    e           ddd           n# 1 swxY w Y    edd          5 Ze                    e           ddd           n# 1 swxY w Y    ed            eg d            eg d            edd          5 Ze                    e           e                    e           ddd           n# 1 swxY w Y    edd          5 Ze                    e           ddd           n# 1 swxY w Y    e              edd          \  ZZ edd          5 Ze                    e           e                    e           ddd           n# 1 swxY w Y    edd           \  ZZ ed!d          5 Ze                    e           e                    e           ddd           n# 1 swxY w Y    edd           \  ZZ ed"d          5 Ze                    e           e                    e           ddd           n# 1 swxY w Y    ed#dd$%          \  ZZ ed&d          5 Ze                    e           e                    e           ddd           n# 1 swxY w Y   g d'Z ed(dd)                    e          *          \  ZZ ed+d          5 Ze                    e           e                    e           ddd           n# 1 swxY w Y   g d,Z ed-dd)                    e          *          \  ZZ ed.d          5 Ze                    e           e                    e           ddd           n# 1 swxY w Y    ed/dd01          \  ZZ ed2d          5 Ze                    e           e                    e           ddd           n# 1 swxY w Y    e              ed3            ed            ed!           dS dS )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   t          d| z              g }t          d          D ]I}t          j        d          5 }|                    |j                   d d d            n# 1 swxY w Y   J|\  }}	}
	 t                              | |t          t                    }t          |d          5 }|                    |           d d d            n# 1 swxY w Y   ddd	d
dd|d|
d|d|g}|rVt          j        d          5 }|                    |j                   |j        }d d d            n# 1 swxY w Y   |d|gz  }n|dd|	gz  }t          dg|z              |r#dd|d|d|	dddddd|g}t          dg|z              t          |	d          5 }|                                }d d d            n# 1 swxY w Y   t          |
d          5 }|                                }d d d            n# 1 swxY w Y   ||f|D ]}t          j        |           S # |D ]}t          j        |           w xY w)Nzcreating 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formatr   r   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/lib/python3.11/test/make_ssl_certs.pymake_cert_keyr>   w   s   	

)***I1XX % %(666 	%!QV$$$	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	% 	%$-!Hi+!!	 " 
 
 (C   	AGGCLLL	 	 	 	 	 	 	 	 	 	 	 	 	 	 	vx&3	8s8%  	2,E::: !a  (((&! ! ! ! ! ! ! ! ! ! ! ! ! ! ! VW&&DD Wfi11DI;%&&& 
	+8s	7,*gD 	{T)*** )S!! 	Q6688D	 	 	 	 	 	 	 	 	 	 	 	 	 	 	(C   	A&&((C	 	 	 	 	 	 	 	 	 	 	 	 	 	 	Sy 	 	DIdOOOO	I 	 	DIdOOOO	s   A""A&	)A&	58H -CH CH C)H  "D."H .D22H 5D26AH F2&H 2F66H 9F6:H G."H .G22H 5G26H H1r   c                  8    t          j        t                     d S )N)shutilrmtree	TMP_CADIR     r=   	unmake_carE      s    
M)rD   c                     t          j        t                     t          t           j                            dd          d          5 } 	 d d d            n# 1 swxY w Y   t          t           j                            dd          d          5 } |                     d           d d d            n# 1 swxY w Y   t          t           j                            dd          d          5 } |                     d           d d d            n# 1 swxY w Y   t          t           j                            dd	          d
          5 } |                     d           d d d            n# 1 swxY w Y   t          j        d
          5 }t          
                    ddt          t                    }|                    |           |                                 t          j                    5 } dd|j        ddddddd| j        ddg}t          dg|z              dd|j        ddddt          ddd d!d"d#| j        g}t          dg|z              dd|j        d$dd%g}t          dg|z              d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          g d&           t!          j        d'd(           d S ))Nr   z	index.txta+zcrl.txt00zindex.txt.attrzw+zunique_subject = noserialr   zCB2D80995A69525B
zour-ca-serverr   r   r   r   r   r   r   r   r   zpycakey.pemr   z-subjzG/C=XY/L=Castle Anthrax/O=Python Software Foundation CA/CN=our-ca-serverr   r   pycacert.pemr    r   z-keyfilez	-selfsignr   v3_car!   z-gencrlzrevocation.crl)r   x509-inrJ   r   capath/ceff1710.0rN   zcapath/b1930218.0)r/   mkdirrB   r+   pathjoinr,   r%   r&   r)   r*   r   r   flushr(   r-   r@   copy)r6   tr   r:   s       r=   make_carU      s   HY	bgll7;//	5	5               	bgll79--d	3	3 q	              	bgll7#344T	:	: 'a	%&&&' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 
bgll78,,c	2	2 &a	$%%%& & & & & & & & & & & & & & & 
	$S	)	) +Q!!$	 " 
 
 	
				(** 	+a9affz}AFfhD 	{T)***)QVNHiQVND 	{T)***)QVY@PQD	{T)***	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	+ 	++ + + + + + + + + + + + + + +4        K#%899999s   AAAB11B58B5*DDDE''E+.E+A%J+B I7+J7I;	;J>I;	?JJJc                 \    dd l }t          j        |                    |                      d S )Nr   )_sslpprint_test_decode_cert)rP   rW   s     r=   
print_certrZ      s/    KKK
M$((../////rD   __main__	localhostreq_x509_extensions_simple)r2   zssl_cert.pemr   ssl_key.pemz5password protecting ssl_key.pem in ssl_key.passwd.pem)	r   pkeyrM   r^   r   zssl_key.passwd.pem-aes256-passoutpass:somepass)	r   r_   rM   r^   r   keycert.passwd.pemr`   ra   rb   zkeycert.pemrc   rG   fakehostnamezkeycert2.pemT)r1   zkeycert3.pemzkeycert4.pemzlocalhost-ecczparam:secp384r1.pem)r1   r3   zkeycertecc.pem)	z0otherName.1 = 1.2.3.4;UTF8:some other identifierz/otherName.2 = 1.3.6.1.5.2.2;SEQUENCE:princ_namezemail.1 = user@example.orgzDNS.2 = www.example.orgzdirName.1 = dir_sectzURI.1 = https://www.python.org/zIP.1 = 127.0.0.1z
IP.2 = ::1zRID.1 = 1.2.3.4.5allsans
)r1   r   zallsans.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idnsanszidnsans.pemnosanreq_x509_extensions_nosan)r1   r2   z	nosan.pemz>update Lib/test/test_ssl.py and Lib/test/test_asyncio/utils.py)Fr   r   r   )__doc__r/   rX   r@   r%   
subprocessr   r   r)   rP   abspathdirname__file__herer>   rB   rE   rU   rZ   __name__chdirr<   r3   r+   r6   r,   r#   r-   r   rQ   rC   rD   r=   <module>rr      s    
			       	
eN 
wrwx0011 356@3 3 3 3j 	  ): ): ):X0 0 0
 zBHTNNNk/KLLLID#	nc	"	" a	              	mS	!	! Q	              	E
ABBBJvvvwwwJvvvwww	mS	!	! Q		               
"D	)	) Q	               GIIIn2NOOOID#	nc	"	" a		               k555ID#	nc	"	" a		               n4888ID#	nc	"	" a		               d(=  ID# 
	$	$ 		                I iddii	>R>RSSSID#	mS	!	! Q		              	 	 	I iddii	>R>RSSSID#	mS	!	! Q		               gD6QRRRID#	k3		 1		               IKKK	E
JKKKJ}J~m s   B55B9<B9C..C25C2*+E!!E%(E%8FF!F+HH	H)+I  I$'I$+J>>KK&+LL!$L!+NNN+P		PP1+Q((Q,/Q,