Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/crypto/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/crypto/openssl_pkcs12.pyo

�
�Udac@`sMddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZddlZdZyddlmZWn#ek
r�ej�ZeZnXeZdd
lmZmZddlmZddlmZmZdejfd��YZdej fd��YZ!d�Z"e#dkrIe"�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bysK

---
module: openssl_pkcs12
author:
- Guillaume Delpierre (@gdelpierre)
version_added: "2.7"
short_description: Generate OpenSSL PKCS#12 archive
description:
    - This module allows one to (re-)generate PKCS#12.
requirements:
    - python-pyOpenSSL
options:
    action:
        description:
            - C(export) or C(parse) a PKCS#12.
        type: str
        default: export
        choices: [ export, parse ]
    other_certificates:
        description:
            - List of other certificates to include. Pre 2.8 this parameter was called C(ca_certificates)
        type: list
        elements: path
        aliases: [ ca_certificates ]
    certificate_path:
        description:
            - The path to read certificates and private keys from.
            - Must be in PEM format.
        type: path
    force:
        description:
            - Should the file be regenerated even if it already exists.
        type: bool
        default: no
    friendly_name:
        description:
            - Specifies the friendly name for the certificate and private key.
        type: str
        aliases: [ name ]
    iter_size:
        description:
            - Number of times to repeat the encryption step.
        type: int
        default: 2048
    maciter_size:
        description:
            - Number of times to repeat the MAC step.
        type: int
        default: 1
    passphrase:
        description:
            - The PKCS#12 password.
        type: str
    path:
        description:
            - Filename to write the PKCS#12 file to.
        type: path
        required: true
    privatekey_passphrase:
        description:
            - Passphrase source to decrypt any input private keys with.
        type: str
    privatekey_path:
        description:
            - File to read private key from.
        type: path
    state:
        description:
            - Whether the file should exist or not.
              All parameters except C(path) are ignored when state is C(absent).
        choices: [ absent, present ]
        default: present
        type: str
    src:
        description:
            - PKCS#12 file path to parse.
        type: path
    backup:
        description:
            - Create a backup file including a timestamp so you can get the original
              output file back if you overwrote it with a new one by accident.
        type: bool
        default: no
        version_added: "2.8"
extends_documentation_fragment:
    - files
seealso:
- module: openssl_certificate
- module: openssl_csr
- module: openssl_dhparam
- module: openssl_privatekey
- module: openssl_publickey
s�
- name: Generate PKCS#12 file
  openssl_pkcs12:
    action: export
    path: /opt/certs/ansible.p12
    friendly_name: raclette
    privatekey_path: /opt/certs/keys/key.pem
    certificate_path: /opt/certs/cert.pem
    other_certificates: /opt/certs/ca.pem
    state: present

- name: Change PKCS#12 file permission
  openssl_pkcs12:
    action: export
    path: /opt/certs/ansible.p12
    friendly_name: raclette
    privatekey_path: /opt/certs/keys/key.pem
    certificate_path: /opt/certs/cert.pem
    other_certificates: /opt/certs/ca.pem
    state: present
    mode: '0600'

- name: Regen PKCS#12 file
  openssl_pkcs12:
    action: export
    src: /opt/certs/ansible.p12
    path: /opt/certs/ansible.p12
    friendly_name: raclette
    privatekey_path: /opt/certs/keys/key.pem
    certificate_path: /opt/certs/cert.pem
    other_certificates: /opt/certs/ca.pem
    state: present
    mode: '0600'
    force: yes

- name: Dump/Parse PKCS#12 file
  openssl_pkcs12:
    action: parse
    src: /opt/certs/ansible.p12
    path: /opt/certs/ansible.pem
    state: present

- name: Remove PKCS#12 file
  openssl_pkcs12:
    path: /opt/certs/ansible.p12
    state: absent
s�
filename:
    description: Path to the generate PKCS#12 file.
    returned: changed or success
    type: str
    sample: /opt/certs/ansible.p12
privatekey:
    description: Path to the TLS/SSL private key the public key was generated from.
    returned: changed or success
    type: str
    sample: /etc/ssl/private/ansible.com.pem
backup_file:
    description: Name of backup file created.
    returned: changed and if I(backup) is C(yes)
    type: str
    sample: /path/to/ansible.com.pem.2019-03-09@11:22~
N(tcrypto(t
AnsibleModuletmissing_required_lib(tto_bytest	to_nativet	PkcsErrorcB`seZRS((t__name__t
__module__(((sI/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_pkcs12.pyR
�stPkcscB`sMeZd�Zed�Zd�Zd�Zd�Zd�Zdd�Z
RS(cC`s tt|�j|jd|jd|jd|j�|jd|_|jd|_|jd|_|jd|_|jd|_	|jd	|_
|jd
|_d|_
|jd|_|jd|_|jd
|_|jddkrd|jd<n|jd|_d|_dS(Ntpathtstatetforcetactiontother_certificatestcertificate_patht
friendly_namet	iter_sizetmaciter_sizet
passphrasetprivatekey_passphrasetprivatekey_pathtsrctmodet0400tbackup(tsuperRt__init__tparamst
check_modeRRRRRRRtNonetpkcs12RRRR tbackup_file(tselftmodule((sI/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_pkcs12.pyR"�s(



	c	`s�tt��j||�}�fd�}|s4|Stjj�j�ry|jddkry�j|�}�j�_y�j	�\}}}}	Wnt
jk
r�tSX|dk	r��jdk	r�t
jt
j�jj��}
||
krtSnt|�t�j�krtS|dk	rb�jdk	rbt
jt
j�jj��}||kr�tSnt|�t�j�kr�tS|dk	r��jdk	r�g�jj�D]}t
jt
j|�^q�}
t|�t|
�krtSnt|�t�j�krtS|r}�jj�dk	rN|	dk	rN�jj�|	krstSqvt�jj��t|	�krvtSq}ntS|�S(s,Ensure the resource is in its desired state.c`sV�jrRytj�j�j�WqRtjk
r:tStjk
rNtSXntS(N(	Rtcrypto_utilstload_privatekeyRRtErrortFalsetOpenSSLBadPassphraseErrortTrue((R((sI/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_pkcs12.pyt_check_pkey_passphrase�s	RtexportN(R!RtchecktosRtexistsR#tgenerateRtparseRR,R-R%Rtdump_privatekeytFILETYPE_PEMR&tget_privatekeytboolRtdump_certificatetget_certificateRtget_ca_certificatestsettget_friendlyname(R(R)tperms_requiredtstate_and_permsR0tdummytpkcs12_privatekeytpkcs12_certificatetpkcs12_other_certificatestpkcs12_friendly_namet
expected_pkeyt
expected_certt
other_certtexpected_other_certs((R(sI/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_pkcs12.pyR2�sP(.!!
cC`sFi|jd6}|jr)|j|d<n|jrB|j|d<n|S(s'Serialize the object into a dictionary.tfilenameRR'(RRR'(R(tresult((sI/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_pkcs12.pytdumps
		cC`stj�|_|jrPg|jD]}tj|�^q"}|jj|�n|jrx|jjtj|j��n|j	r�|jj
t|j	��n|jr�y&|jj
tj|j|j��Wq�tjk
r�}t|��q�Xn|jj|j|j|j�S(sGenerate PKCS#12 file archive.(RtPKCS12R&RR*tload_certificatetset_ca_certificatesRtset_certificateRtset_friendlynameRRtset_privatekeyR+RR.R
R1RRR(R(R)RItother_certstexc((sI/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_pkcs12.pyR5,s$	"			cC`s;|jr!|j|j�|_ntt|�j|�dS(N(R tbackup_localRR'R!Rtremove(R(R)((sI/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_pkcs12.pyRWGs	c
C`sy�t|jd��}|j�}WdQXtj||j�}tjtj|j��}tj	tj|j
��}g}|j�dk	r�g|j�D]}tj	tj|�^q�}n|j
�}||||fSWntk
r�}	t|	��nXdS(sRead PKCS#12 file.trbN(topenRtreadRtload_pkcs12RR7R8R9R;R<R=R%R?tIOErrorR
(
R(t	pkcs12_fhtpkcs12_contenttp12tpkeytcrtRTRIRRU((sI/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_pkcs12.pyR6Ls"	.cC`s8|jr!|j|j�|_ntj|||�dS(sWrite the PKCS#12 file.N(R RVRR'R*t
write_file(R(R)tcontentR((sI/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_pkcs12.pytwriteds	N(RRR"R/R2RMR5RWR6R%Rd(((sI/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_pkcs12.pyR�s	@	
			c!C`s|tdtdddddddg�dtdd	d
ddd
g�dtdd�dtdddt�dtddddg�dtdddd�dtdddd�dtdddt�dtdddt�dtdddt�dtdd�dtdddddddg�d tdd�d!tdddt��}ddd ggg}td"td#|d$|d%t�}ts�|jd&td'�d(t�ntj	j
|jd�p�d)}tj	j|�s�|jd|d&d*|�ny_t
|�}t}|jddkrh|jrX|j�}|jdpA|j|�|d+<|j|�n|j|d,t�s{|jdr8|jddkr�|jds�|jd&d-�n|j|�}|j||d.�t}q8|j�\}}	}
}d/t|�t|	�td0j|
��f}|j|t|��n|j|j�}
|j|
|�r�t}q�nq|jr�|j�}tj	j|jd�|d+<|j|�ntj	j|jd�r�|j|�t}n|j�}||d+<tj	j|jd�r;d1tjtj|jd�j�}||d2<n|j|�Wn,tj k
rw}|jd&t|��nXdS(3NRttypetstrtdefaultR1tchoicesR6RtlisttelementsRtaliasestca_certificatesRRR:RtnameRtintiRiRtno_logtrequiredRRRtpresenttabsentRR tadd_file_common_argst
argument_spectrequired_iftsupports_check_modetmsgt	pyOpenSSLt	exceptiont.s@The directory '%s' does not exist or the path is not a directorytchangedR@sFriendly_name is requiredi�s%s%s%sts%04oR(!tdictR-R/R	tpyopenssl_foundt	fail_jsonR
tPYOPENSSL_IMP_ERRR3RtdirnameR#tisdirRR$RMR2t	exit_jsonR5RdR6RtjoinRtload_file_common_argumentstset_fs_attributes_if_differentR4RWtstattS_IMODEtst_modeR*tOpenSSLObjectError(RtRuR)tbase_dirR&R{RLR^R`tcertRTRtdump_contentt	file_argst	file_modeRU((sI/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_pkcs12.pytmainks�!!			!#
	.	
	
&
t__main__($t
__future__RRRRet
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR�R3t	tracebackR%R�tOpenSSLRtImportErrort
format_excR-R~R/tansible.module_utils.basicR	R
tansible.module_utilsR*tansible.module_utils._textRRR�R
t
OpenSSLObjectRR�R(((sI/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_pkcs12.pyt<module>s2


^0

�	U

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]