File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/win_pki.cpython-310.pyc
Back
o ;j?D � @ s� d Z ddlZddlZddlZddlZddlZddlZddlZddl m Z mZ dZdZ dZe�e�ZdZdd � Zd"dd�Zd d� Zdd� Zdd� Zeefdd�Ze dfdd�Ze eedddfdd�Ze eedfdd�Zeed ddfdd�Zeefd d!�ZdS )#a� Microsoft certificate management via the PKI Client PowerShell module. https://technet.microsoft.com/en-us/itpro/powershell/windows/pkiclient/pkiclient The PKI Client PowerShell module is only available on Windows 8+ and Windows Server 2012+. https://technet.microsoft.com/en-us/library/hh848636(v=wps.620).aspx :platform: Windows :depends: - PowerShell 4 - PKI Client Module (Windows 8+ / Windows Server 2012+) .. versionadded:: 2016.11.0 � N)�CommandExecutionError�SaltInvocationErrorZLocalMachine�cerZMyZwin_pkic C sV t jj�� sdS t jj�td d�dkrdS td d�d s d S t jj� d �s)dS t S )z� Requires Windows Requires Windows 8+ / Windows Server 2012+ Requires PowerShell Requires PKI Client PowerShell module installed. )Fz!Only available on Windows SystemsZ osversionz6.2.9200���)Fz4Only available on Windows 8+ / Windows Server 2012 +zcmd.shell_info� powershellZ installed)FzPowershell not availableZPKI)Fz#PowerShell PKI module not available)�salt�utils�platformZ is_windowsZversionsZversion_cmpZ __grains__�__salt__r Z module_exists�__virtualname__� r r �H/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/win_pki.py�__virtual__% s r Fc C s� dg}|r|� d�| �� n|� | � td d�|�ddd�}|d r-td �| |d ���|rNztjjj|d dd�}|W S t yM td �|d ���w |d S )zh Ensure that the Pki module is loaded, and convert to and extract data from Json as needed. zImport-Module -Name PKI; z4ConvertTo-Json -Compress -Depth 4 -InputObject @({})zcmd.run_all� r T)�shellZpython_shell�stderrz'Unable to execute command: {} Error: {}�stdoutF)�strictz'Unable to parse return data as JSON: {}) �append�formatr �joinr r r �json�loads� ValueError)�cmd�as_jsonZcmd_fullZcmd_ret�itemsr r r �_cmd_run; s. � ����r c C s. d| � d�}t �t|d��std| � ���dS )zS Ensure that the certificate path, as determind from user input, is valid. zTest-Path -Path '�'�r zInvalid path specified: N)�ast�literal_evalr r )�namer r r r �_validate_cert_path] s �r# c C s$ ddg}| |vrt d�| |���dS )zU Ensure that the certificate format, as determind from user input, is valid. r �pfxz<Invalid certificate format '{}' specified. Valid formats: {}N)r r )r"