Anons79 Mini Shell

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

�
�Udac@`s_ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
mZmZddl
mZdd
lmZddlmZddlmZddlmZmZddlmZmZmZmZddlZddlZddlZddl Z dZ!dZ"dZ$yddlm%Z%Wn#e&k
r[e j'�Z$e(Z)nXe*Z)dZ+y/ddl,Z,dd
l,mZee,j-�Z.Wn#e&k
r�e j'�Z+e(Z/nXe*Z/dZ0yGddl1Z1ddl2Z1ddl3Z1ddl4m5Z6ee1j-�Z7Wn#e&k
r5e j'�Z0e(Z8nXe*Z8d�Z9e:dkr[e9�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys�
---
module: get_certificate
author: "John Westcott IV (@john-westcott-iv)"
version_added: "2.8"
short_description: Get a certificate from a host:port
description:
    - Makes a secure connection and returns information about the presented certificate
    - The module can use the cryptography Python library, or the pyOpenSSL Python
      library. By default, it tries to detect which one is available. This can be
      overridden with the I(select_crypto_backend) option. Please note that the PyOpenSSL
      backend was deprecated in Ansible 2.9 and will be removed in Ansible 2.13."
options:
    host:
      description:
        - The host to get the cert for (IP is fine)
      type: str
      required: true
    ca_cert:
      description:
        - A PEM file containing one or more root certificates; if present, the cert will be validated against these root certs.
        - Note that this only validates the certificate is signed by the chain; not that the cert is valid for the host presenting it.
      type: path
    port:
      description:
        - The port to connect to
      type: int
      required: true
    proxy_host:
      description:
        - Proxy host used when get a certificate.
      type: str
      version_added: 2.9
    proxy_port:
      description:
        - Proxy port used when get a certificate.
      type: int
      default: 8080
      version_added: 2.9
    timeout:
      description:
        - The timeout in seconds
      type: int
      default: 10
    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.
      type: str
      default: auto
      choices: [ auto, cryptography, pyopenssl ]
      version_added: "2.9"

notes:
  - When using ca_cert on OS X it has been reported that in some conditions the validate will always succeed.

requirements:
  - "python >= 2.7 when using C(proxy_host)"
  - "cryptography >= 1.6 or pyOpenSSL >= 0.15"
s�
cert:
    description: The certificate retrieved from the port
    returned: success
    type: str
expired:
    description: Boolean indicating if the cert is expired
    returned: success
    type: bool
extensions:
    description: Extensions applied to the cert
    returned: success
    type: list
    elements: dict
    contains:
        critical:
            returned: success
            type: bool
            description: Whether the extension is critical.
        asn1_data:
            returned: success
            type: str
            description: The Base64 encoded ASN.1 content of the extnesion.
        name:
            returned: success
            type: str
            description: The extension's name.
issuer:
    description: Information about the issuer of the cert
    returned: success
    type: dict
not_after:
    description: Expiration date of the cert
    returned: success
    type: str
not_before:
    description: Issue date of the cert
    returned: success
    type: str
serial_number:
    description: The serial number of the cert
    returned: success
    type: str
signature_algorithm:
    description: The algorithm used to sign the cert
    returned: success
    type: str
subject:
    description: Information about the subject of the cert (OU, CN, etc)
    returned: success
    type: dict
version:
    description: The version number of the certificate
    returned: success
    type: str
s9
- name: Get the cert from an RDP port
  get_certificate:
    host: "1.2.3.4"
    port: 3389
  delegate_to: localhost
  run_once: true
  register: cert

- name: Get a cert from an https port
  get_certificate:
    host: "www.google.com"
    port: 443
  delegate_to: localhost
  run_once: true
  register: cert

- name: How many days until cert expires
  debug:
    msg: "cert expires in: {{ expire_days }} days."
  vars:
    expire_days: "{{ (( cert.not_after | to_datetime('%Y%m%d%H%M%SZ')) - (ansible_date_time.iso8601 | to_datetime('%Y-%m-%dT%H:%M:%SZ')) ).days }}"
(t
AnsibleModuletmissing_required_lib(tto_bytes(tcrypto(tLooseVersion(tisfile(tsetdefaulttimeouttsocket(tget_server_certificatetDER_cert_to_PEM_certt	CERT_NONEt
CERT_OPTIONALNs0.15s1.6(tcreate_default_context(tdefault_backendcC`swtdtdtdd�dtdddt�dtdd	dt�d
tdd�dtdd	dd
�dtdd	dd�dtddddddgdd���}|jjd�}|jjd�}|jjd�}|jjd
�}|jjd�}|jjd�}|jjd�}|dkr�toGttt�k}t	o_t
tt�k}	|rqd}n|	r�d}n|dkr�|jddj
tt��q�n|dkr�t	s�|jdtdj
t��dt�n|jddd�n=|dkr;ts;|jdtdj
t��dt�q;ntdt�}
|r]t|�n|r�t|�s�|jdd�q�n|r�ts�|jdddt�ny�d ||f}t�}tj|j�|j||f�|j|j��|jd!�t�}
t|
_ t!|
_"|rFt#|
_"|
j$d"|�n|
j%|d#|�j&t�}t'|�}Wq�t(k
r�}|jdd$j
|��q�XnKyt)||fd%|�}Wn,t(k
r�}|jdd$j
|��nX||
d&<|dkrmt*j+t*j,|�}i|
d'<x0|j-�j.�D]}|d(|
d'|d)<q6W|j/�|
d*<g|
d+<|j0�}x^t1d)|�D]M}|j2|�}|
d+j3i|j4�d,6|j5�d-6|j6�d.6�q�Wi|
d/<x0|j7�j.�D]}|d(|
d/|d)<q�W|j8�|
d0<|j9�|
d1<|j:�|
d2<|j;�|
d3<|j<�|
d<n�|dkrft=j>j?t@|�tA��}i|
d'<x4|jBD])}|jC|
d'tDjE|jFd4t�<q�W|jGtHjHjI�k|
d*<g|
d+<x~tDjJ|�jK�D]g\}}t=j>jFjL|�}|
d+j3i|d,d,6tMjN|d5�d-6tDjE|d4t�d.6�qWi|
d/<x4|jOD])}|jC|
d/tDjE|jFd4t�<q�W|jGjPd6�|
d0<|jQjPd6�|
d1<|jR|
d2<tDjE|jS�|
d3<|jTt=j>jUjVkr4d9|
d<qf|jTt=j>jUjWkrYd:|
d<qfd8|
d<n|jX|
�dS(;Nt
argument_spectca_certttypetpaththosttstrtrequiredtporttintt
proxy_hostt
proxy_porttdefaulti�ttimeouti
tselect_crypto_backendtchoicestautot	pyopenssltcryptographytmsgs]Can't detect any of the required Python libraries cryptography (>= {0}) or PyOpenSSL (>= {1})spyOpenSSL >= {0}t	exceptionsKThe module is using the PyOpenSSL backend. This backend has been deprecatedtversions2.13scryptography >= {0}tchangedsca_cert file does not existsTTo use proxy_host, you must run the get_certificate module with Python 2.7 or newer.sCONNECT %s:%s HTTP/1.0

i tcafiletserver_hostnames,Failed to get cert from port with error: {0}tca_certstcerttsubjectiitexpiredt
extensionstcriticalt	asn1_datatnametissuert	not_aftert
not_beforet
serial_numbertsignature_algorithmtshorttvalues
%Y%m%d%H%M%SZitunknownii(YRtdicttTruetparamstgettCRYPTOGRAPHY_FOUNDtCRYPTOGRAPHY_VERSIONRtMINIMAL_CRYPTOGRAPHY_VERSIONtPYOPENSSL_FOUNDtPYOPENSSL_VERSIONtMINIMAL_PYOPENSSL_VERSIONt	fail_jsontformatR	tPYOPENSSL_IMP_ERRt	deprecatetCRYPTOGRAPHY_IMP_ERRtFalseRR
tHAS_CREATE_DEFAULT_CONTEXTtCREATE_DEFAULT_CONTEXT_IMP_ERRRtatexittregistertclosetconnecttsendtencodetrecvRtcheck_hostnameRtverify_modeRtload_verify_locationstwrap_sockettgetpeercertRt	ExceptionRRtload_certificatetFILETYPE_PEMtget_subjecttget_componentsthas_expiredtget_extension_counttranget
get_extensiontappendtget_criticaltget_datatget_short_namet
get_issuertget_notAftert
get_notBeforetget_serial_numbertget_signature_algorithmtget_versionR'tx509tload_pem_x509_certificateR
tcryptography_backendR0R<tcrypto_utilstcryptography_oid_to_nametoidtnot_valid_aftertdatetimetutcnowt%cryptography_get_extensions_from_certtitemstObjectIdentifiertbase64t	b64decodeR6tstrftimetnot_valid_beforeR9tsignature_algorithm_oidR*tVersiontv1tv3t	exit_json(tmoduleRRRRR R"tbackendtcan_use_cryptographytcan_use_pyopenssltresultRStsocktctxR/teRot	componenttextension_counttindext	extensiont	attributet
dotted_numbertentryRt((sJ/usr/lib/python2.7/site-packages/ansible/modules/crypto/get_certificate.pytmain�s�*		

	

	
				 







'
"

'



t__main__(;t
__future__RRRRt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtRETURNtEXAMPLEStansible.module_utils.basicRR	tansible.module_utils._textR
tansible.module_utilsRRrtdistutils.versionRtos.pathR
RRtsslRRRRRPR{Rvt	tracebackRGRDtNoneRORtImportErrort
format_excRMRNR?RJtOpenSSLt__version__RFRERLR'tcryptography.exceptionstcryptography.x509tcryptography.hazmat.backendsRRqRCRBR�t__name__(((sJ/usr/lib/python2.7/site-packages/ansible/modules/crypto/get_certificate.pyt<module>sd


?9"





	�

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