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_certificate_info.pyc

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlmZdd
lmZddlmZmZddlmZddlmZmZmZddlmZ dZ!dZ"dZ$y\ddl%Z%dd
l%mZee%j&�Z'e%j(j)dkrmdZ*dZ+ndZ*dZ+Wn#e,k
r�ej-�Z$e.Z/nXe0Z/dZ1y?ddl2Z2ddl2m3Z3ddl4m5Z5ee2j&�Z6Wn#e,k
rej-�Z1e.Z7nXe0Z7dZ8d�Z9dej:fd��YZ;de;fd ��YZ<d!e;fd"��YZ=d#�Z>e?d$kr�e>�ndS(%i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys\

---
module: openssl_certificate_info
version_added: '2.8'
short_description: Provide information of OpenSSL X.509 certificates
description:
    - This module allows one to query information on OpenSSL certificates.
    - It uses the pyOpenSSL or cryptography python library to interact with OpenSSL. If both the
      cryptography and PyOpenSSL libraries are available (and meet the minimum version requirements)
      cryptography will be preferred as a backend over PyOpenSSL (unless the backend is forced with
      C(select_crypto_backend)). Please note that the PyOpenSSL backend was deprecated in Ansible 2.9
      and will be removed in Ansible 2.13.
requirements:
    - PyOpenSSL >= 0.15 or cryptography >= 1.6
author:
  - Felix Fontein (@felixfontein)
  - Yanis Guenane (@Spredzy)
  - Markus Teufelberger (@MarkusTeufelberger)
options:
    path:
        description:
            - Remote absolute path where the certificate file is loaded from.
        type: path
        required: true
    valid_at:
        description:
            - A dict of names mapping to time specifications. Every time specified here
              will be checked whether the certificate is valid at this point. See the
              C(valid_at) return value for informations on the result.
            - Time can be specified either as relative time or as absolute timestamp.
            - Time will always be interpreted as UTC.
            - Valid format is C([+-]timespec | ASN.1 TIME) where timespec can be an integer
              + C([w | d | h | m | s]) (e.g. C(+32w1d2h), and ASN.1 TIME (i.e. pattern C(YYYYMMDDHHMMSSZ)).
              Note that all timestamps will be treated as being in UTC.
        type: dict
    select_crypto_backend:
        description:
            - Determines which crypto backend to use.
            - The default choice is C(auto), which tries to use C(cryptography) if available, and falls back to C(pyopenssl).
            - If set to C(pyopenssl), will try to use the L(pyOpenSSL,https://pypi.org/project/pyOpenSSL/) library.
            - If set to C(cryptography), will try to use the L(cryptography,https://cryptography.io/) library.
            - Please note that the C(pyopenssl) backend has been deprecated in Ansible 2.9, and will be removed in Ansible 2.13.
              From that point on, only the C(cryptography) backend will be available.
        type: str
        default: auto
        choices: [ auto, cryptography, pyopenssl ]

notes:
    - All timestamp values are provided in ASN.1 TIME format, i.e. following the C(YYYYMMDDHHMMSSZ) pattern.
      They are all in UTC.
seealso:
- module: openssl_certificate
s�
- name: Generate a Self Signed OpenSSL certificate
  openssl_certificate:
    path: /etc/ssl/crt/ansible.com.crt
    privatekey_path: /etc/ssl/private/ansible.com.pem
    csr_path: /etc/ssl/csr/ansible.com.csr
    provider: selfsigned


# Get information on the certificate

- name: Get information on generated certificate
  openssl_certificate_info:
    path: /etc/ssl/crt/ansible.com.crt
  register: result

- name: Dump information
  debug:
    var: result


# Check whether the certificate is valid or not valid at certain times, fail
# if this is not the case. The first task (openssl_certificate_info) collects
# the information, and the second task (assert) validates the result and
# makes the playbook fail in case something is not as expected.

- name: Test whether that certificate is valid tomorrow and/or in three weeks
  openssl_certificate_info:
    path: /etc/ssl/crt/ansible.com.crt
    valid_at:
      point_1: "+1d"
      point_2: "+3w"
  register: result

- name: Validate that certificate is valid tomorrow, but not in three weeks
  assert:
    that:
      - result.valid_at.point_1      # valid in one day
      - not result.valid_at.point_2  # not valid in three weeks
s�
expired:
    description: Whether the certificate is expired (i.e. C(notAfter) is in the past)
    returned: success
    type: bool
basic_constraints:
    description: Entries in the C(basic_constraints) extension, or C(none) if extension is not present.
    returned: success
    type: list
    elements: str
    sample: "[CA:TRUE, pathlen:1]"
basic_constraints_critical:
    description: Whether the C(basic_constraints) extension is critical.
    returned: success
    type: bool
extended_key_usage:
    description: Entries in the C(extended_key_usage) extension, or C(none) if extension is not present.
    returned: success
    type: list
    elements: str
    sample: "[Biometric Info, DVCS, Time Stamping]"
extended_key_usage_critical:
    description: Whether the C(extended_key_usage) extension is critical.
    returned: success
    type: bool
extensions_by_oid:
    description: Returns a dictionary for every extension OID
    returned: success
    type: dict
    contains:
        critical:
            description: Whether the extension is critical.
            returned: success
            type: bool
        value:
            description: The Base64 encoded value (in DER format) of the extension
            returned: success
            type: str
            sample: "MAMCAQU="
    sample: '{"1.3.6.1.5.5.7.1.24": { "critical": false, "value": "MAMCAQU="}}'
key_usage:
    description: Entries in the C(key_usage) extension, or C(none) if extension is not present.
    returned: success
    type: str
    sample: "[Key Agreement, Data Encipherment]"
key_usage_critical:
    description: Whether the C(key_usage) extension is critical.
    returned: success
    type: bool
subject_alt_name:
    description: Entries in the C(subject_alt_name) extension, or C(none) if extension is not present.
    returned: success
    type: list
    elements: str
    sample: "[DNS:www.ansible.com, IP:1.2.3.4]"
subject_alt_name_critical:
    description: Whether the C(subject_alt_name) extension is critical.
    returned: success
    type: bool
ocsp_must_staple:
    description: C(yes) if the OCSP Must Staple extension is present, C(none) otherwise.
    returned: success
    type: bool
ocsp_must_staple_critical:
    description: Whether the C(ocsp_must_staple) extension is critical.
    returned: success
    type: bool
issuer:
    description:
        - The certificate's issuer.
        - Note that for repeated values, only the last one will be returned.
    returned: success
    type: dict
    sample: '{"organizationName": "Ansible", "commonName": "ca.example.com"}'
issuer_ordered:
    description: The certificate's issuer as an ordered list of tuples.
    returned: success
    type: list
    elements: list
    sample: '[["organizationName", "Ansible"], ["commonName": "ca.example.com"]]'
    version_added: "2.9"
subject:
    description:
        - The certificate's subject as a dictionary.
        - Note that for repeated values, only the last one will be returned.
    returned: success
    type: dict
    sample: '{"commonName": "www.example.com", "emailAddress": "[email protected]"}'
subject_ordered:
    description: The certificate's subject as an ordered list of tuples.
    returned: success
    type: list
    elements: list
    sample: '[["commonName", "www.example.com"], ["emailAddress": "[email protected]"]]'
    version_added: "2.9"
not_after:
    description: C(notAfter) date as ASN.1 TIME
    returned: success
    type: str
    sample: 20190413202428Z
not_before:
    description: C(notBefore) date as ASN.1 TIME
    returned: success
    type: str
    sample: 20190331202428Z
public_key:
    description: Certificate's public key in PEM format
    returned: success
    type: str
    sample: "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8A..."
public_key_fingerprints:
    description:
        - Fingerprints of certificate's public key.
        - For every hash algorithm available, the fingerprint is computed.
    returned: success
    type: dict
    sample: "{'sha256': 'd4:b3:aa:6d:c8:04:ce:4e:ba:f6:29:4d:92:a3:94:b0:c2:ff:bd:bf:33:63:11:43:34:0f:51:b0:95:09:2f:63',
              'sha512': 'f7:07:4a:f0:b0:f0:e6:8b:95:5f:f9:e6:61:0a:32:68:f1..."
signature_algorithm:
    description: The signature algorithm used to sign the certificate.
    returned: success
    type: str
    sample: sha256WithRSAEncryption
serial_number:
    description: The certificate's serial number.
    returned: success
    type: int
    sample: 1234
version:
    description: The certificate version.
    returned: success
    type: int
    sample: 3
valid_at:
    description: For every time stamp provided in the I(valid_at) option, a
                 boolean whether the certificate is valid at that point in time
                 or not.
    returned: success
    type: dict
subject_key_identifier:
    description:
        - The certificate's subject key identifier.
        - The identifier is returned in hexadecimal, with C(:) used to separate bytes.
        - Is C(none) if the C(SubjectKeyIdentifier) extension is not present.
    returned: success and if the pyOpenSSL backend is I(not) used
    type: str
    sample: '00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33'
    version_added: "2.9"
authority_key_identifier:
    description:
        - The certificate's authority key identifier.
        - The identifier is returned in hexadecimal, with C(:) used to separate bytes.
        - Is C(none) if the C(AuthorityKeyIdentifier) extension is not present.
    returned: success and if the pyOpenSSL backend is I(not) used
    type: str
    sample: '00:11:22:33:44:55:66:77:88:99:aa:bb:cc:dd:ee:ff:00:11:22:33'
    version_added: "2.9"
authority_cert_issuer:
    description:
        - The certificate's authority cert issuer as a list of general names.
        - Is C(none) if the C(AuthorityKeyIdentifier) extension is not present.
    returned: success and if the pyOpenSSL backend is I(not) used
    type: list
    elements: str
    sample: "[DNS:www.ansible.com, IP:1.2.3.4]"
    version_added: "2.9"
authority_cert_serial_number:
    description:
        - The certificate's authority cert serial number.
        - Is C(none) if the C(AuthorityKeyIdentifier) extension is not present.
    returned: success and if the pyOpenSSL backend is I(not) used
    type: int
    sample: '12345'
    version_added: "2.9"
ocsp_uri:
    description: The OCSP responder URI, if included in the certificate. Will be
                 C(none) if no OCSP responder URI is included.
    returned: success
    type: str
    version_added: "2.9"
N(tLooseVersion(tcrypto(t
AnsibleModuletmissing_required_lib(tstring_types(t	to_nativetto_texttto_bytes(t	ipaddresss1.6s0.15it
tlsfeaturetstatus_requests1.3.6.1.5.5.7.1.24sDER:30:03:02:01:05(tx509(t
serializations
%Y%m%d%H%M%SZcC`s�|}|jd�s$|jd�r1tj|�S|d	krVtjd||��nxHddddgD]4}ytjj||�}PWqitk
r�qiXqiWt|tj�s�tjd||f��n|S(
sfReturn an ASN1 formatted string if a relative timespec
       or an ASN1 formatted string is provided.t+t-s%The timespec "%s" for %s is not valids
%Y%m%d%H%M%SZs%Y%m%d%H%MZs%Y%m%d%H%M%S%zs%Y%m%d%H%M%zs$The time spec "%s" for %s is invalidN(	t
startswithtcrypto_utilstconvert_relative_to_datetimetNonetOpenSSLObjectErrortdatetimetstrptimet
ValueErrort
isinstance(tinput_stringt
input_nametresulttdate_fmt((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pytget_relative_time_optionYs$

tCertificateInfocB`s^eZd�Zd�Zd�Zejd��Zejd��Zejd��Z	ejd��Z
ejd��Zejd��Zejd	��Z
ejd
��Zejd��Zejd��Zejd
��Zejd��Zejd��Zejd��Zejd��Zejd��Zejd��Zd�ZRS(cC`s�tt|�j|jddt|j�||_||_|jd|_|jr�xv|jj	�D]b\}}t
|t�s�|jjddj
|t|���nt|dj
|��|j|<qdWndS(Ntpathtpresenttvalid_attmsgs;The value for valid_at.{0} must be of type string (got {1})svalid_at.{0}(tsuperR%t__init__tparamstFalset
check_modetbackendtmoduleR(titemsRRt	fail_jsontformatttypeR$(tselfR0R/tktv((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyR+ss

			cC`sdS(N((R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pytgenerate�scC`sdS(N((R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pytdump�scC`sdS(N((R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyt_get_signature_algorithm�scC`sdS(N((R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyt_get_subject_ordered�scC`sdS(N((R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyt_get_issuer_ordered�scC`sdS(N((R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyt_get_version�scC`sdS(N((R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyt_get_key_usage�scC`sdS(N((R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyt_get_extended_key_usage�scC`sdS(N((R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyt_get_basic_constraints�scC`sdS(N((R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyt_get_ocsp_must_staple�scC`sdS(N((R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyt_get_subject_alt_name�scC`sdS(N((R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyt_get_not_before�scC`sdS(N((R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyt_get_not_after�scC`sdS(N((R5tbinary((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyt_get_public_key�scC`sdS(N((R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyt_get_subject_key_identifier�scC`sdS(N((R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyt_get_authority_key_identifier�scC`sdS(N((R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyt_get_serial_number�scC`sdS(N((R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyt_get_all_extensions�scC`sdS(N((R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyt
_get_ocsp_uri�scC`s�t�}tj|jd|j�|_|j�|d<|j�}|j�}t�|d<x"|D]\}}||d|<qcW||d<t�|d<x"|D]\}}||d|<q�W||d<|j	�|d<|j
�\|d<|d	<|j�\|d
<|d<|j�\|d<|d
<|j
�\|d<|d<|j�\|d<|d<|j�}|j�}|jt�|d<|jt�|d<|tjj�k|d<t�|d<|jr
xD|jj�D]0\}}||ko�|kn|d|<q�Wn|jdt�|d<|jdt�}|dk	rPtj|�nt�|d<|jdkr~|j�}	|	dk	r�ttj|	��}	dj gt!dt"|	�d�D]}
|	|
|
d!^q��}	n|	|d<|j#�\}}}
|dk	r]ttj|��}dj gt!dt"|�d�D]}
||
|
d!^q:�}n||d<||d<|
|d <n|j$�|d!<|j%�|d"<|j&�|d#<|S($NR/tsignature_algorithmtsubjecttsubject_orderedtissuertissuer_orderedtversiont	key_usagetkey_usage_criticaltextended_key_usagetextended_key_usage_criticaltbasic_constraintstbasic_constraints_criticaltocsp_must_stapletocsp_must_staple_criticaltsubject_alt_nametsubject_alt_name_criticalt
not_beforet	not_aftertexpiredR(REt
public_keytpublic_key_fingerprintst	pyopensslt:iitsubject_key_identifiertauthority_key_identifiertauthority_cert_issuertauthority_cert_serial_numbert
serial_numbertextensions_by_oidtocsp_uri('tdictRtload_certificateR&R/tcertR:R;R<R=R>R?R@RARBRCRDtstrftimetTIMESTAMP_FORMATRtutcnowR(R1RFR-tTrueRtget_fingerprint_of_bytesRGR
tbinasciithexlifytjointrangetlenRHRIRJRK(R5R"RMROR6R7R\R]tpktskititakitacitacsn((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pytget_info�s`	




	+(B
B


(t__name__t
__module__R+R8R9tabctabstractmethodR:R;R<R=R>R?R@RARBRCRDRFRGRHRIRJRKR}(((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyR%rs*			tCertificateInfoCryptographycB`s�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�ZRS(s:Validate the supplied cert, using the cryptography backendcC`stt|�j|d�dS(Ntcryptography(R*R�R+(R5R0((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyR+scC`stj|jj�S(N(Rtcryptography_oid_to_nameRltsignature_algorithm_oid(R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyR:scC`sCg}x6|jjD](}|jtj|j�|jg�qW|S(N(RlRMtappendRR�toidtvalue(R5R"t	attribute((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyR;s&cC`sCg}x6|jjD](}|jtj|j�|jg�qW|S(N(RlROR�RR�R�R�(R5R"R�((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyR<s&cC`s<|jjtjjkrdS|jjtjjkr8dSdS(Niitunknown(RlRQRtVersiontv1tv3(R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyR=!s
cC`sHy#|jjjtj�}|j}td|jd|jd|j	d|j
d|jd|jd|j
dtd	t�	}|dr�|jtd|jd	|j��ntdd
dddddd
ddddddddd	d�	}tg|j�D]\}}|r�||^q��|jfSWntjjk
rCdtfSXdS(Ntdigital_signaturetcontent_commitmenttkey_enciphermenttdata_enciphermentt
key_agreementt
key_cert_signtcrl_signt
encipher_onlyt
decipher_onlysDigital SignaturesNon RepudiationsKey EnciphermentsData Encipherments
Key AgreementsCertificate SignsCRL Signs
Encipher Onlys
Decipher Only(Rlt
extensionstget_extension_for_classRtKeyUsageR�RjR�R�R�R�R�R�R�R-tupdateR�R�tsortedR1tcriticalR�tExtensionNotFoundR(R5tcurrent_key_exttcurrent_key_usageRRtkey_usage_namestnameR�((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyR>(s@									
		/cC`ssyN|jjjtj�}tg|jD]}tj|�^q(�|j	fSWnt
jjk
rndt
fSXdS(N(RlR�R�RtExtendedKeyUsageR�R�RR�R�R�R�RR-(R5text_keyusage_extteku((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyR?Ns%cC`s�y�|jjjtj�}g}|jdj|jjr?dnd��|jj	dk	rz|jdj|jj	��nt|�|jfSWnt
jjk
r�dtfSXdS(NsCA:{0}tTRUEtFALSEspathlen:{0}(RlR�R�RtBasicConstraintsR�R3R�tcatpath_lengthRR�R�R�R�R-(R5R�R"((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyR@Ws(cC`s�y�y4|jjjtj�}tjjj|jk}WnLt	k
r�}tj
jd�}|jjj|�}|jjdk}nX||j
fSWntjjk
r�dtfSXdS(Ns1.3.6.1.5.5.7.1.24s0(RlR�R�Rt
TLSFeatureR�tTLSFeatureTypeRR�tAttributeErrorR�tObjectIdentifiertget_extension_for_oidR�R�RR-(R5ttlsfeature_extR�tdummyR�((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyRAbscC`ssyN|jjjtj�}g|jD]}tj|�^q%}||jfSWnt	jj
k
rndtfSXdS(N(
RlR�R�RtSubjectAlternativeNameR�Rtcryptography_decode_nameR�R�R�RR-(R5tsan_exttsanR"((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyRBqs%cC`s
|jjS(N(Rltnot_valid_before(R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyRCyscC`s
|jjS(N(Rltnot_valid_after(R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyRD|scC`s7|jj�j|r!tjjn	tjjtjj�S(N(	RlR_tpublic_bytesRtEncodingtDERtPEMtPublicFormattSubjectPublicKeyInfo(R5RE((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyRFscC`sEy&|jjjtj�}|jjSWntjjk
r@dSXdS(N(
RlR�R�RtSubjectKeyIdentifierR�tdigestR�R�R(R5text((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyRG�s
cC`s�yx|jjjtj�}d}|jjdk	r^g|jjD]}tj	|�^q@}n|jj
||jjfSWntjj
k
r�dSXdS(N(NNN(RlR�R�RtAuthorityKeyIdentifierRR�ReRR�tkey_identifierRfR�R�(R5R�ROR�((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyRH�s+cC`s
|jjS(N(RlRg(R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyRI�scC`stj|j�S(N(Rt%cryptography_get_extensions_from_certRl(R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyRJ�scC`s�yj|jjjtj�}xK|jD]@}|jtjjj	kr%t
|jtj�re|jjSq%q%WWntj
k
r�}nXdS(N(RlR�R�RtAuthorityInformationAccessR�t
access_methodR�tAuthorityInformationAccessOIDtOCSPRtaccess_locationtUniformResourceIdentifierR�R(R5R�tdescR�((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyRK�s(R~Rt__doc__R+R:R;R<R=R>R?R@RARBRCRDRFRGRHRIRJRK(((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyR�
s&						&										
		tCertificateInfoPyOpenSSLcB`s�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZRS(s"validate the supplied certificate.cC`stt|�j|d�dS(NRa(R*R�R+(R5R0((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyR+�scC`st|jj��S(N(RRltget_signature_algorithm(R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyR:�scC`sKg}x>|j�D]0}|jtj|d�t|d�g�qW|S(Nii(tget_componentsR�Rtpyopenssl_normalize_nameR(R5R�R"tsub((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyt
__get_name�s.cC`s|j|jj��S(N(t#_CertificateInfoPyOpenSSL__get_nameRltget_subject(R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyR;�scC`s|j|jj��S(N(R�Rlt
get_issuer(R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyR<�scC`s|jj�dS(Ni(Rltget_version(R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyR=�scC`s�x�td|jj��D]�}|jj|�}|j�|krgt|dd�jd�D]}tj|j	��^q_}t
|�t|j��fSqWdtfS(Niterrorstsurrogate_or_strictt,(RuRltget_extension_countt
get_extensiontget_short_nameRtsplitRR�tstripR�tbooltget_criticalRR-(R5t
short_namet
extension_idxt	extensiontusageR"((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyt_get_extension�s= cC`s
|jd�S(NtkeyUsage(R�(R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyR>�scC`s
|jd�S(NtextendedKeyUsage(R�(R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyR?�scC`s
|jd�S(NtbasicConstraints(R�(R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyR@�scC`sgtd|jj��D]}|jj|�^q}g|D]6}t|j��tkr>t|�tkr>|^q>}tj	j
dkr�|jg|D]0}|j�dkr�|j�dkr�|^q��n|r�t
t|dj��fSdtfSdS(NiitUNDEFs0(RuRlR�R�RR�tOPENSSL_MUST_STAPLE_NAMEtOPENSSL_MUST_STAPLE_VALUEtOpenSSLtSSLtOPENSSL_VERSION_NUMBERtextendtget_dataRpR�R�RR-(R5RyR�R�toms_ext((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyRA�s7
6GcC`sa|jd�r&d|td�}n|jd�r]tj|d�}dj|j�}n|S(NsIP Address:sIP:isIP:{0}(RRvtcompat_ipaddresst
ip_addressR3t
compressed(R5R�tip((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyt_normalize_san�scC`s�x�td|jj��D]}}|jj|�}|j�dkrgt|dd�jd�D]}|j|j��^q_}|t	|j
��fSqWdtfS(NitsubjectAltNameR�R�s, (
RuRlR�R�R�RR�R�R�R�R�RR-(R5R�R�taltnameR"((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyRB�s:cC`s(t|jj��}tjj|d�S(Ns
%Y%m%d%H%M%SZ(R
Rlt
get_notBeforeRR(R5ttime_string((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyRC�scC`s(t|jj��}tjj|d�S(Ns
%Y%m%d%H%M%SZ(R
Rltget_notAfterRR(R5R�((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyRD�scC`s�y/tj|rtjntj|jj��SWn�tk
r�y�tj�}|rxtjj	||jj�j
�}n!tjj||jj�j
�}|dkr�tj�ntj
|�SWq�tk
r�|jjd�q�XnXdS(Nis�Your pyOpenSSL version does not support dumping public keys. Please upgrade to version 16.0 or newer, or use the cryptography backend.(R	tdump_publickeyt
FILETYPE_ASN1tFILETYPE_PEMRlt
get_pubkeyR�t_new_mem_buft_libti2d_PUBKEY_biot_pkeytPEM_write_bio_PUBKEYt_raise_current_errort_bio_to_stringR0twarn(R5REtbiotrc((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyRF�s
$!

cC`sdS(N(R(R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyRGscC`sdS(N(NNN(R(R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyRHscC`s
|jj�S(N(Rltget_serial_number(R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyRIscC`stj|j�S(N(Rt"pyopenssl_get_extensions_from_certRl(R5((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyRJscC`s�x~t|jj��D]g}|jj|�}|j�dkrt|�}tjd|dtj�}|r}|j	d�SqqWdS(NtauthorityInfoAccesss^OCSP - URI:(.*)$tflagsi(RuRlR�R�R�tstrtretsearcht	MULTILINEtgroupR(R5RyR�R7tm((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyRKs(R~RR�R+R:R�R;R<R=R�R>R?R@RAR�RBRCRDRFRGRHRIRJRK(((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyR��s,							
														cC`sptdtdtdddt�dtdd�dtddd	d
dd
dd
g��dt�}y�tjj|jd�pd}tjj|�s�|jd|dd|�n|jd}|d
krFt	o�t
tt�k}t
o�ttt�k}|r	d}n|rd
}n|d
krF|jddjtt��qFn|d
kr�t
s�|jdtdjt��dt�nyttjd�Wn!tk
r�|jdd�nX|jddd�t|�}nI|dkr#t	s|jdtdjt��dt�nt|�}n|j�}|j|�Wn,tjk
rk}|jdt|��nXdS(Nt
argument_specR&R4trequiredR(Rjtselect_crypto_backendRtdefaulttautotchoicesR�Ratsupports_check_modet.R�R)s>The directory %s does not exist or the file is not a directorys]Can't detect any of the required Python libraries cryptography (>= {0}) or PyOpenSSL (>= {1})spyOpenSSL >= {0}t	exceptiontget_extensionss You need to have PyOpenSSL>=0.15sKThe module is using the PyOpenSSL backend. This backend has been deprecatedRQs2.13scryptography >= {0}( R
RjRptosR&tdirnameR,tisdirR2tCRYPTOGRAPHY_FOUNDtCRYPTOGRAPHY_VERSIONRtMINIMAL_CRYPTOGRAPHY_VERSIONtPYOPENSSL_FOUNDtPYOPENSSL_VERSIONtMINIMAL_PYOPENSSL_VERSIONR3RtPYOPENSSL_IMP_ERRtgetattrR	tX509ReqR�t	deprecateR�tCRYPTOGRAPHY_IMP_ERRR�R}t	exit_jsonRRR
(R0tbase_dirR/tcan_use_cryptographytcan_use_pyopenssltcertificateR"texc((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pytmain*sV'		
		


t__main__(@t
__future__RRRR4t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR�RrRRR
t	tracebacktdistutils.versionRtansible.module_utilsR	Rtansible.module_utils.basicR
Rtansible.module_utils.sixRtansible.module_utils._textR
RRtansible.module_utils.compatRR�R!R$RR%R�t__version__R#R�R�R�R�tImportErrort
format_excR-R"RpR)R�Rtcryptography.hazmat.primitivesRR RRnR$t
OpenSSLObjectR%R�R�R0R~(((sS/usr/lib/python2.7/site-packages/ansible/modules/crypto/openssl_certificate_info.pyt<module>sj


6)�	




	���	<

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