Current File : //usr/local/apps/python3/lib/python3.11/test/__pycache__/make_ssl_certs.cpython-311.pyc |
�
�Ke�$ � �D � d Z ddlZddlZddlZddlZddlT dZdZdZej �
ej � e� � � � Z
d4d�ZdZd
� Zd� Zd� Zedk �r9 ej e
� � edd�� � \ ZZ edd� � 5 Ze� e� � ddd� � n# 1 swxY w Y edd� � 5 Ze� e� � ddd� � n# 1 swxY w Y ed� � eg d�� � eg d�� � edd� � 5 Ze� e� � e� e� � ddd� � n# 1 swxY w Y edd� � 5 Ze� e� � ddd� � n# 1 swxY w Y e� � edd�� � \ ZZ edd� � 5 Ze� e� � e� e� � ddd� � n# 1 swxY w Y edd� � � \ ZZ ed!d� � 5 Ze� e� � e� e� � ddd� � n# 1 swxY w Y edd� � � \ ZZ ed"d� � 5 Ze� e� � e� e� � ddd� � n# 1 swxY w Y ed#dd$�%� � \ ZZ ed&d� � 5 Ze� e� � e� e� � ddd� � n# 1 swxY w Y g d'�Z ed(dd)� e� � �*� � \ ZZ ed+d� � 5 Ze� e� � e� e� � ddd� � n# 1 swxY w Y g d,�Z ed-dd)� e� � �*� � \ ZZ ed.d� � 5 Ze� e� � e� e� � ddd� � n# 1 swxY w Y ed/dd0�1� � \ ZZ ed2d� � 5 Ze� e� � e� e� � ddd� � n# 1 swxY w Y e� � ed3� � ed� � ed!� � dS dS )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 swxY w Y �J|\ }} }
t � | |t t �� � }t |d� � 5 }|� |� � d d d � � n# 1 swxY w Y ddd d
dd|d
|
d|d|g
}|rVt j d�� � 5 }|� |j � � |j }
d d d � � n# 1 swxY w Y |d|
gz
}n|dd| gz
}t dg|z � � |r#dd|d|d| dddddd|
g}t dg|z � � t | d� � 5 }|�
� � }d d d � � n# 1 swxY w Y t |
d� � 5 }|�
� � }d d d � � n# 1 swxY w Y ||f|D ]}t j |� � �S # |D ]}t j |� � �w xY w)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�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/local/apps/python3/lib/python3.11/test/make_ssl_certs.py�
make_cert_keyr>