File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/mac_keychain.cpython-310.pyc
Back
o ;j� � @ s� d Z ddlZddlZddlZddlZe�e�ZdZ dd� Z ddd �Z dd d�Zddd �Z ddd�Zddd�Zddd�Zdd� Zddd�ZdS ) zO Install certificates into the keychain on Mac OS .. versionadded:: 2016.3.0 � N�keychainc C s t jj�� rtS dS )z Only work on Mac OS )Fz+Only available on Mac OS systems with pipes)�salt�utils�platformZ is_darwin�__virtualname__� r r �M/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/mac_keychain.py�__virtual__ s r �"/Library/Keychains/System.keychainFc C s@ |dur t ||� d| � d|� d|� �}|r|d7 }td |�S )a� Install a certificate cert The certificate to install password The password for the certificate being installed formatted in the way described for openssl command in the PASS PHRASE ARGUMENTS section. Note: The password given here will show up as plaintext in the job returned info. keychain The keychain to install the certificate to, this defaults to /Library/Keychains/System.keychain allow_any Allow any application to access the imported certificate without warning keychain_password If your keychain is likely to be locked pass the password and it will be unlocked before running the import Note: The password given here will show up as plaintext in the returned job info. CLI Example: .. code-block:: bash salt '*' keychain.install test.p12 test123 Nzsecurity import z -P z -k z -A�cmd.run��unlock_keychain�__salt__)�cert�passwordr Z allow_any�keychain_password�cmdr r r �install s ( r c C s. |dur t ||� d| � d|� �}td |�S )aB Uninstall a certificate from a keychain cert_name The name of the certificate to remove keychain The keychain to install the certificate to, this defaults to /Library/Keychains/System.keychain keychain_password If your keychain is likely to be locked pass the password and it will be unlocked before running the import Note: The password given here will show up as plaintext in the returned job info. CLI Example: .. code-block:: bash salt '*' keychain.install test.p12 test123 Nz security delete-certificate -c "z" r r )Z cert_namer r r r r r � uninstallM s r c C s2 d� t�| ��}td |dd�}|�dd��d�S )a List all of the installed certificates keychain The keychain to install the certificate to, this defaults to /Library/Keychains/System.keychain CLI Example: .. code-block:: bash salt '*' keychain.list_certs zUsecurity find-certificate -a {} | grep -o "alis.*" | grep -o '\"[-A-Za-z0-9.:() ]*\"'r T�Zpython_shell�"� � )�format�shlex�quoter �replace�split)r r �outr r r � list_certsn s �r c C sL d}|r |� d�}d� |t�| �t�|��}td |dd�}|�dd��� S ) ag Get the friendly name of the given certificate cert The certificate to install password The password for the certificate being installed formatted in the way described for openssl command in the PASS PHRASE ARGUMENTS section Note: The password given here will show up as plaintext in the returned job info. legacy Assume legacy format for certificate. CLI Example: .. code-block:: bash salt '*' keychain.get_friendly_name /tmp/test.p12 test123 salt '*' keychain.get_friendly_name /tmp/test.p12 test123 legacy=True zopenssl pkcs12z -legacyzP{} -in {} -passin pass:{} -info -nodes -nokeys 2> /dev/null | grep friendlyName:r Tr zfriendlyName: r )r r r r r �strip)r r �legacyZopenssl_cmdr r r r r �get_friendly_name� s ��r"