← Back
Editing: crypto_util.cpython-38.pyc
U �]c? � @ s� d Z ddlZddlZddlZddlZddlZddlZddlm Z ddlm Z ddlmZ ddl mZ ddlmZ ddlmZ dd lmZ dd lmZ ddlmZ ddlmZ dd lmZ ddlmZ ddlmZ ddlm Z ddl!m"Z" e�#e$�Z%dEdd�Z&dd� Z'dd� Z(dd� Z)dd� Z*dd� Z+dd � Z,d!d"� Z-d#d$� Z.d%d&� Z/d'd(� Z0d)d*� Z1d+d,� Z2e j3fd-d.�Z4e j3fd/d0�Z5e j3fd1d2�Z6d3d4� Z7d5d6� Z8e j3fd7d8�Z9e j3fd9d:�Z:d;d<� Z;d=d>� Z<d?d@� Z=dAdB� Z>dCdD� Z?dS )Fz�Certbot client crypto utility functions. .. todo:: Make the transition to use PSS rather than PKCS1_v1_5 when the server is capable of handling the signatures. � N)�SSL)�crypto)�x509)�InvalidSignature)�default_backend)�ECDSA)�EllipticCurvePublicKey)�PKCS1v15)�RSAPublicKey)�crypto_util)�IO)�errors)� interfaces)�util)�os�key-certbot.pemc C s� zt | �}W n4 tk r@ } ztjddd� |�W 5 d}~X Y nX tj�tj�}t � |d|j� t �t j�||�dd�\}}|� |�|� W 5 Q R X t�d| |� t �||�S ) a� Initializes and saves a privkey. Inits key and saves it in PEM format on the filesystem. .. note:: keyname is the attempted filename, it may be different if a file already exists at the path. :param int key_size: RSA key size in bits :param str key_dir: Key save directory. :param str keyname: Filename of key :returns: Key :rtype: :class:`certbot.util.Key` :raises ValueError: If unable to generate the key given key_size. � T��exc_infoNi� i� �wbzGenerating key (%d bits): %s)�make_key� ValueError�logger�error�zope� component� getUtilityr �IConfigr �make_or_verify_dir�strict_permissions�unique_filer �path�join�write�debugZKey)Zkey_sizeZkey_dirZkeynameZkey_pem�err�configZkey_f�key_path� r( �5/usr/lib/python3/dist-packages/certbot/crypto_util.py� init_save_key% s �r* c C s� t j�tj�}tj| j||jd�}t � |d|j� t �t j�|d�dd�\}}|� |�|� W 5 Q R X t�d|� t �||d�S )a2 Initialize a CSR with the given private key. :param privkey: Key to include in the CSR :type privkey: :class:`certbot.util.Key` :param set names: `str` names to include in the CSR :param str path: Certificate save directory. :returns: CSR :rtype: :class:`certbot.util.CSR` )�must_staplei� zcsr-certbot.pemi� r zCreating CSR: %s�pem)r r r r r �acme_crypto_utilZmake_csrr, r+ r r r r r r! r"