File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/zmq/auth/__pycache__/certs.cpython-310.pyc
Back
o ;j� � @ s2 d Z ddlZddlZddlZddlmZmZmZmZ ddl Z dZ dZ ddeeej f ded eeef d eeeef deeeef ded dfdd�Z ddeeej f dedeeeef d eeef fdd�Zdeeej f d eeee f fdd�Zddeeej f d eeef fdd�Zg d�ZdS )z10MQ authentication related functions and classes.� N)�Dict�Optional�Tuple�Unionz�# **** Generated on {0} by pyzmq **** # ZeroMQ CURVE **Secret** Certificate # DO NOT PROVIDE THIS FILE TO OTHER USERS nor change its permissions. a # **** Generated on {0} by pyzmq **** # ZeroMQ CURVE Public Certificate # Exchange securely, or use a secure mechanism to verify the contents # of this file after exchange. Store public certificates in your home # directory, in the .curve subdirectory. �utf-8�key_filename�banner� public_key� secret_key�metadata�encoding�returnc C s t |t�r |�|�}t |t�r|�|�}t| ddd��e}|�|�tj�� �� |�d� |rW|�� D ]$\}}t |t�r@|�|�}t |t�rJ|�|�}|�d|� d|� d�� q2|�d� |�d |� d �� |rx|�d|� d �� W d � dS W d � dS 1 s�w Y dS ) zCreate a certificate file�w�utf8)r z metadata z z = � zcurve z public-key = "z" z secret-key = "N) � isinstance�bytes�decode�open�write�format�datetime�now�items) r r r r r r �f�k�v� r �B/opt/saltstack/salt/lib/python3.10/site-packages/zmq/auth/certs.py�_write_key_file s* �"�r �key_dir�namec C sj t �� \}}tj�| |�}|� d�}|� d�}tj�� }t|t� |�|� t|t � |�|||d� ||fS )zeCreate zmq certificates. Returns the file paths to the public and secret certificate files. z.key_secretz.key)r r )�zmqZ curve_keypair�os�path�joinr r r �_cert_public_bannerr �_cert_secret_banner) r r! r r r � base_filenameZsecret_key_fileZpublic_key_filer r r r �create_certificates= s �r) �filenamec C s� d}d}t j�| �std| � ���t| d��=}|D ]2}|�� }|�d�r%q|�d�r5|�dd�d �d�}|�d �rE|�dd�d �d�}|rK|rK nqW d � n1 sVw Y |du rftd | � ���||fS )a Load public and secret key from a zmq certificate. Returns (public_key, secret_key) If the certificate file only contains the public key, secret_key will be None. If there is no public key found in the file, ValueError will be raised. NzInvalid certificate file: �rb� #s public-key� =� s '"s secret-keyzNo public key found in ) r# r$ �exists�OSErrorr �strip� startswith�split� ValueError)r* r r r �liner r r �load_certificateY s( ��r6 �.� directoryc C s\ i }t j�| �std| � ���t j�| d�}t�|�}|D ]}t|�\}}|r+d||<