a ‚oe{£ã@s UddlZddlZddlZddlZddlmZddlmZddlmZddlm Z m Z m Z m Z m Z mZmZmZmZmZmZddlmZmZddlmZmZmZmZmZddlmZdd lm Z!dd lm"Z#dd lm$Z%dd lm&Z'dd lm(Z)ddlm*Z+ddlm,Z-gd¢Z.eej/ej0ej1ej2fZ3ee4e5efZ6ee5e de5ffZ7e'j8Z9e:e;d<e'je'j?Z@e:e;d<e'jAZBe:e;d<e'jCZDe:e;d<e'jEZFe:e;d<Gdd„deGƒZHee#eHƒZIe)eHƒZJe4e dœdd„ZKd{ee5e dœdd „ZLe e5d!œd"d#„ZMe e5dd$œd%d&„ZNe5e d'œd(d)„ZOe ee5d*œd+d,„ZPGd-d.„d.ƒZQGd/d0„d0ƒZRGd1d2„d2ƒZSed2d3œd4d5„ZTe4eSd6œd7d8„ZUejVGd9d:„d:ƒƒZWGd;d<„d<ƒZXeXZYejZeXe[d=e\d�Gd?d@„d@ƒZ]GdAdB„dBƒZ^GdCdD„dDƒZ_GdEdF„dFƒZ`GdGdH„dHeGƒZaGdIdJ„dJƒZbe:e5e^dKœdLdM„Zce:e^e5dNœdOdP„Zde:eRe5dQœdRdS„Zed|e:eRee4ee7e5dTœdUdV„ZfGdWdX„dXƒZgegZhejZege[dYe\dXd>�GdZd[„d[ƒZieiZjejZeie[dYe\d[d>�Gd\d]„d]ƒZkejZeke[d^e\d]d>�Gd_d`„d`ƒZlejZele[dae\d`d>�Gdbdc„dcƒZme:ee4e5feRdKœddde„Znd}e:ee4e5fee7eRdfœdgdh„Zoe:e]e5diœdjdk„Zpe:e5e]dKœdldm„ZqeRee4e5fe4e5dnœdodp„ZrejZere[dqe\dpd>�e^e5ee4e5fe4ddrœdsdt„ZsejZese[due\dtd>�e:eje5dvœdwdx„ZtetZuejZete[dYe\dxd>�e:ee4e5fejdKœdydz„ZvevZwejZeve[dYe\dzd>�dS)~éN)Ú b16encode)Úpartial)ÚPathLike) ÚAnyÚCallableÚIterableÚListÚNoReturnÚOptionalÚSequenceÚSetÚTupleÚTypeÚUnion)ÚutilsÚx509)ÚdsaÚecÚed448Úed25519Úrsa)Ú UNSPECIFIED)Ú byte_string)Úexception_from_error_queue)Úffi)Úlib)Ú make_assert)Ú path_bytes)Útext_to_bytes_and_warn)!Ú FILETYPE_PEMÚ FILETYPE_ASN1Ú FILETYPE_TEXTÚTYPE_RSAÚTYPE_DSAÚErrorÚPKeyÚget_elliptic_curvesÚget_elliptic_curveÚX509NameÚ X509ExtensionÚX509ReqÚX509ÚX509StoreFlagsÚ X509StoreÚX509StoreContextErrorÚX509StoreContextÚload_certificateÚdump_certificateÚdump_publickeyÚdump_privatekeyÚRevokedÚCRLÚPKCS12Ú NetscapeSPKIÚload_publickeyÚload_privatekeyÚdump_certificate_requestÚload_certificate_requestÚsignÚverifyÚdump_crlÚload_crl.rr iÿÿr"r#ÚTYPE_DHÚTYPE_ECc@seZdZdZdS)r$z7 An error occurred in an `OpenSSL.crypto` API. N)Ú__name__Ú __module__Ú __qualname__Ú__doc__©rFrFú/C:\Program Files\Certbot\pkgs\OpenSSL\crypto.pyr$psr$)ÚwhereÚreturncCstd|›d�ƒ‚dS)zÐ An OpenSSL API failed somehow. Additionally, the failure which was encountered isn't one that's exercised by the test suite so future behavior of pyOpenSSL is now somewhat less predictable. zUnknown z failureN)Ú RuntimeError)rHrFrFrGÚ_untested_errorzsrK)ÚbufferrIcCsn|durt t ¡¡}tj}n2t d|¡}t |t|ƒ¡}|ftttdœdd„}t |tj kƒt  ||¡}|S)zÙ Allocate a new OpenSSL memory BIO. Arrange for the garbage collector to clean it up automatically. :param buffer: None or some bytes to use to put into the BIO so that they can be read out. Núchar[])ÚbioÚrefrIcSs t |¡S©N)Ú_libÚBIO_free)rNrOrFrFrGÚfree”sz_new_mem_buf..free) rQZBIO_newZ BIO_s_memrRÚ_ffiÚnewZBIO_new_mem_bufÚlenrÚ_openssl_assertÚNULLÚgc)rLrNrSÚdatarFrFrGÚ _new_mem_bufƒs   r[)rNrIcCs.t d¡}t ||¡}t |d|¡dd…S)zO Copy the contents of an OpenSSL BIO object into a Python byte string. zchar**rN)rTrUrQZBIO_get_mem_datarL)rNÚ result_bufferZ buffer_lengthrFrFrGÚ_bio_to_string�s  r])ÚboundaryÚwhenrIcCs@t|tƒstdƒ‚t|tjkƒt ||¡}|dkrt t |¡¡St d¡}t  ||¡|dtj krlt dƒn6t d|d¡}t |¡}t |¡}t  |d¡|SdS)a] Retrieve the time value of an ASN1 time object. @param timestamp: An ASN1_GENERALIZEDTIME* (or an object safely castable to that type) from which the time value will be retrieved. @return: The time value from C{timestamp} as a L{bytes} string in a certain format. Or C{None} if the object contains no time value. ú ASN1_STRING*rNzASN1_GENERALIZEDTIME**ÚASN1_TIME_to_generalizedtime) rTÚcastrQÚASN1_STRING_lengthZASN1_STRING_typeZV_ASN1_GENERALIZEDTIMEÚstringÚASN1_STRING_get0_datarUrmrXrKZASN1_GENERALIZEDTIME_free)rkZstring_timestampZgeneralized_timestampZ string_dataÚ string_resultrFrFrGÚ_get_asn1_timeÒs" ÿ   ÿ  rsc@s8eZdZddœdd„Zdddœdd„Zddœd d „ZdS) Ú_X509NameInvalidatorN©rIcCs g|_dSrP)Ú_names©ÚselfrFrFrGÚ__init__üsz_X509NameInvalidator.__init__r(©ÚnamerIcCs|j |¡dSrP)rvÚappend©rxr{rFrFrGÚaddÿsz_X509NameInvalidator.addcCs|jD]}|`qdSrP)rvÚ_namer}rFrFrGÚclears z_X509NameInvalidator.clear)rBrCrDryr~r€rFrFrFrGrtûsrtc@s„eZdZdZdZdZddœdd„Zedœdd „Ze edd œd d „ƒZ e e dd œdd„Z e dœdd„Ze dœdd„Ze dœdd„ZdS)r%zD A class representing an DSA or RSA public key or key pair. FTNrucCs"t ¡}t |tj¡|_d|_dS)NF)rQZ EVP_PKEY_newrTrYÚ EVP_PKEY_freeÚ_pkeyÚ _initialized©rxÚpkeyrFrFrGrysz PKey.__init__cCs@ddlm}m}|jr(tt|ƒ}||ƒStt|ƒ}||dƒSdS)a Export as a ``cryptography`` key. :rtype: One of ``cryptography``'s `key interfaces`_. .. _key interfaces: https://cryptography.io/en/latest/hazmat/ primitives/asymmetric/rsa/#key-interfaces .. versionadded:: 16.1.0 r)Úload_der_private_keyÚload_der_public_keyN)Ú,cryptography.hazmat.primitives.serializationr†r‡Ú _only_publicr2r r3)rxr†r‡ÚderrFrFrGÚto_cryptography_keys   zPKey.to_cryptography_key)Ú crypto_keyrIc Cs�t|tjtjtjtjtjt j t j fƒs.t dƒ‚ddlm}m}m}m}t|tjtjfƒrntt| |j|j¡ƒS| |j|j|ƒ¡}tt|ƒSdS)zø Construct based on a ``cryptography`` *crypto_key*. :param crypto_key: A ``cryptography`` key. :type crypto_key: One of ``cryptography``'s `key interfaces`_. :rtype: PKey .. versionadded:: 16.1.0 zUnsupported key typer)ÚEncodingÚ NoEncryptionÚ PrivateFormatÚ PublicFormatN)r`rÚ RSAPublicKeyÚ RSAPrivateKeyrÚ DSAPublicKeyÚ DSAPrivateKeyrZEllipticCurvePrivateKeyrZEd25519PrivateKeyrZEd448PrivateKeyrbrˆr�rŽr�r�r8r Ú public_bytesÚDERZSubjectPublicKeyInfoZ private_bytesZPKCS8r9)ÚclsrŒr�rŽr�r�rŠrFrFrGÚfrom_cryptography_key,s0 ùþ ÿþ ÿzPKey.from_cryptography_key)ÚtypeÚbitsrIc Cs6t|tƒstdƒ‚t|tƒs$tdƒ‚|tkr¢|dkr= 0`` :raises TypeError: If :py:data:`type` or :py:data:`bits` isn't of the appropriate type. :raises ValueError: If the number of bits isn't an integer of the appropriate size. :return: ``None`` útype must be an integerzbits must be an integerrzInvalid number of bitsézNo such key typeTN)r`Úintrbr"rcrQÚBN_newrTrYÚBN_freeZ BN_set_wordZRSA_F4ZRSA_newZRSA_generate_key_exrXrWZEVP_PKEY_assign_RSAr‚r#ZDSA_newZDSA_freeZDSA_generate_parameters_exZDSA_generate_keyZEVP_PKEY_set1_DSAr$rƒ)rxr™ršZexponentrÚresultrÚresrFrFrGÚ generate_keyZs6    ÿ zPKey.generate_keycCsd|jrtdƒ‚t | ¡¡tjkr*tdƒ‚t |j¡}t  |tj ¡}t  |¡}|dkrZdSt ƒdS)ax Check the consistency of an RSA private key. This is the Python equivalent of OpenSSL's ``RSA_check_key``. :return: ``True`` if key is consistent. :raise OpenSSL.crypto.Error: if the key is inconsistent. :raise TypeError: if the key is of a type which cannot be checked. Only RSA keys can currently be checked. zpublic key onlyz'Only RSA keys can currently be checked.rœTN) r‰rbrQZ EVP_PKEY_typer™Ú EVP_PKEY_RSAÚEVP_PKEY_get1_RSAr‚rTrYÚRSA_freeZ RSA_check_keyÚ_raise_current_error)rxrr rFrFrGÚcheck’s   z PKey.checkcCs t |j¡S)zT Returns the type of the key :return: The type of the key. )rQÚ EVP_PKEY_idr‚rwrFrFrGr™¬sz PKey.typecCs t |j¡S)zh Returns the number of bits of the key :return: The number of bits of the key. )rQZ EVP_PKEY_bitsr‚rwrFrFrGrš´sz PKey.bits)rBrCrDrEr‰rƒryÚ_Keyr‹Ú classmethodr˜r�r¢Úboolr§r™ršrFrFrFrGr%s-8r%cs¢eZdZdZdZeedœ‡fdd„ Zeee ddœdd„ƒZ eee ddœd d „ƒZ eee dd œd d „ƒZ ee eddœdd„Zedœdd„Zedœdd„Z‡ZS)Ú_EllipticCurveaZ A representation of a supported elliptic curve. @cvar _curves: :py:obj:`None` until an attempt is made to load the curves. Thereafter, a :py:type:`set` containing :py:type:`_EllipticCurve` instances each of which represents one curve supported by the system. @type _curves: :py:type:`NoneType` or :py:type:`set` N©ÚotherrIcst|tƒrtƒ |¡StS)z· Implement cooperation with the right-hand side argument of ``!=``. Python 3 seems to have dropped this cooperation in this very narrow circumstance. )r`r¬ÚsuperÚ__ne__ÚNotImplemented©rxr®©Ú __class__rFrGr°És  z_EllipticCurve.__ne__)rrIcs>ˆ tjd¡}t d|¡}ˆ ||¡t‡‡fdd„|DƒƒS)zü Get the curves supported by OpenSSL. :param lib: The OpenSSL library binding object. :return: A :py:type:`set` of ``cls`` instances giving the names of the elliptic curves the underlying library supports. rzEC_builtin_curve[]c3s|]}ˆ ˆ|j¡VqdSrP)Úfrom_nidÚnid)Ú.0Úc©r—rrFrGÚ äóz7_EllipticCurve._load_elliptic_curves..)ZEC_get_builtin_curvesrTrXrUÚset)r—rZ num_curvesZbuiltin_curvesrFr¹rGÚ_load_elliptic_curvesÔs   z$_EllipticCurve._load_elliptic_curvescCs|jdur| |¡|_|jS)a Get, cache, and return the curves supported by OpenSSL. :param lib: The OpenSSL library binding object. :return: A :py:type:`set` of ``cls`` instances giving the names of the elliptic curves the underlying library supports. N)Ú_curvesr½r¹rFrFrGÚ_get_elliptic_curvesæs  z#_EllipticCurve._get_elliptic_curves)rr¶rIcCs|||t | |¡¡ d¡ƒS)aË Instantiate a new :py:class:`_EllipticCurve` associated with the given OpenSSL NID. :param lib: The OpenSSL library binding object. :param nid: The OpenSSL NID the resulting curve object will represent. This must be a curve NID (and not, for example, a hash NID) or subsequent operations will fail in unpredictable ways. :type nid: :py:class:`int` :return: The curve object. Úascii)rTrpÚ OBJ_nid2snÚdecode)r—rr¶rFrFrGrµôsz_EllipticCurve.from_nid)rr¶r{rIcCs||_||_||_dS)a‰ :param _lib: The :py:mod:`cryptography` binding instance used to interface with OpenSSL. :param _nid: The OpenSSL NID identifying the curve this object represents. :type _nid: :py:class:`int` :param name: The OpenSSL short name identifying the curve this object represents. :type name: :py:class:`unicode` N)rQÚ_nidr{)rxrr¶r{rFrFrGrys z_EllipticCurve.__init__rucCsd|j›d�S)Nz©r{rwrFrFrGÚ__repr__sz_EllipticCurve.__repr__cCs|j |j¡}t |tj¡S)zÅ Create a new OpenSSL EC_KEY structure initialized to use this curve. The structure is automatically garbage collected when the Python object is garbage collected. )rQZEC_KEY_new_by_curve_namerÃrTrYZ EC_KEY_free)rxÚkeyrFrFrGÚ _to_EC_KEYsz_EllipticCurve._to_EC_KEY)rBrCrDrEr¾rr«r°rªr r½r¿r�rµÚstrryrÆrÈÚ __classcell__rFrFr³rGr¬½s   r¬rucCs t t¡S)a“ Return a set of objects representing the elliptic curves supported in the OpenSSL build in use. The curve objects have a :py:class:`unicode` ``name`` attribute by which they identify themselves. The curve objects are useful as values for the argument accepted by :py:meth:`Context.set_tmp_ecdh` to specify which elliptical curve should be used for ECDHE key exchange. )r¬r¿rQrFrFrFrGr&$s r&rzcCs,tƒD]}|j|kr|Sqtd|ƒ‚dS)aT Return a single curve object selected by name. See :py:func:`get_elliptic_curves` for information about curve objects. :param name: The OpenSSL short name identifying the curve object to retrieve. :type name: :py:class:`unicode` If the named curve is not supported then :py:class:`ValueError` is raised. zunknown curve nameN)r&r{rc)r{ZcurverFrFrGr'3s   r'cs²eZdZdZdddœdd„Zeeddœ‡fdd„ Zeeedœd d „Z ee d œd d „Z ee d œdd„Z edœdd„Z edœdd„Zedœdd„Zeeeefdœdd„Z‡ZS)r(a An X.509 Distinguished Name. :ivar countryName: The country of the entity. :ivar C: Alias for :py:attr:`countryName`. :ivar stateOrProvinceName: The state or province of the entity. :ivar ST: Alias for :py:attr:`stateOrProvinceName`. :ivar localityName: The locality of the entity. :ivar L: Alias for :py:attr:`localityName`. :ivar organizationName: The organization name of the entity. :ivar O: Alias for :py:attr:`organizationName`. :ivar organizationalUnitName: The organizational unit of the entity. :ivar OU: Alias for :py:attr:`organizationalUnitName` :ivar commonName: The common name of the entity. :ivar CN: Alias for :py:attr:`commonName`. :ivar emailAddress: The e-mail address of the entity. NrzcCs t |j¡}t |tj¡|_dS)zž Create a new X509Name, copying the given X509Name instance. :param name: The name to copy. :type name: :py:class:`X509Name` N)rQÚ X509_NAME_duprrTrYÚX509_NAME_freer}rFrFrGry_s zX509Name.__init__)r{ÚvaluerIc s| d¡rtƒ ||¡St|ƒtur8td t|ƒj¡ƒ‚t  t |ƒ¡}|tj krvz t ƒWnt ylYn0tdƒ‚tt |j¡ƒD]J}t |j|¡}t |¡}t |¡}||kr†t |j|¡}t |¡qÒq†t|tƒræ| d¡}t |j|tj|ddd¡}|�s t ƒdS)NÚ_z,attribute name must be string, not '{:.200}'úNo such attributeúutf-8éÿÿÿÿr)Ú startswithr¯Ú __setattr__r™rÉrbÚformatrBrQÚ OBJ_txt2nidÚ _byte_stringÚ NID_undefr¦r$ÚAttributeErrorÚrangeÚX509_NAME_entry_countrÚX509_NAME_get_entryÚX509_NAME_ENTRY_get_objectÚ OBJ_obj2nidZX509_NAME_delete_entryZX509_NAME_ENTRY_freer`ÚencodeZX509_NAME_add_entry_by_NIDZ MBSTRING_UTF8) rxr{rÍr¶ÚiÚentZent_objZent_nidÚ add_resultr³rFrGrÓis<  ÿÿ        ÿzX509Name.__setattr__c CsÚt t|ƒ¡}|tjkr>z tƒWnty4Yn0tdƒ‚t |j|d¡}|dkrZdSt  |j|¡}t  |¡}t   d¡}t  ||¡}t|dkƒz0t  |d|¡dd… d¡}Wt |d¡nt |d¡0|S)a  Find attribute. An X509Name object has the following attributes: countryName (alias C), stateOrProvince (alias ST), locality (alias L), organization (alias O), organizationalUnit (alias OU), commonName (alias CN) and more... rÏrÑNúunsigned char**rrÐ)rQrÕrÖr×r¦r$rØZX509_NAME_get_index_by_NIDrrÛÚX509_NAME_ENTRY_get_datarTrUZASN1_STRING_to_UTF8rWrLrÂÚ OPENSSL_free) rxr{r¶Z entry_indexÚentryrZr\Z data_lengthr rFrFrGÚ __getattr__‘s*       ÿ zX509Name.__getattr__r­cCs"t|tƒstSt |j|j¡dkS©Nr©r`r(r±rQZ X509_NAME_cmprr²rFrFrGÚ__eq__¹s zX509Name.__eq__cCs"t|tƒstSt |j|j¡dkSrçrèr²rFrFrGÚ__lt__¿s zX509Name.__lt__rucCsDt dd¡}t |j|t|ƒ¡}t|tjkƒd t  |¡  d¡¡S)z6 String representation of an X509Name rMizrÐ) rTrUrQZX509_NAME_onelinerrVrWrXrÔrprÂ)rxr\Z format_resultrFrFrGrÆÅs  ÿÿzX509Name.__repr__cCs t |j¡S)a& Return an integer representation of the first four bytes of the MD5 digest of the DER representation of the name. This is the Python equivalent of OpenSSL's ``X509_NAME_hash``. :return: The (integer) hash of this name. :rtype: :py:class:`int` )rQZX509_NAME_hashrrwrFrFrGÚhashÓs z X509Name.hashcCsNt d¡}t |j|¡}t|dkƒt |d|¡dd…}t |d¡|S)zŽ Return the DER encoding of this name. :return: The DER encoded form of this name. :rtype: :py:class:`bytes` rârN)rTrUrQZ i2d_X509_NAMErrWrLrä)rxr\Z encode_resultrrrFrFrGrŠßs   z X509Name.derc Csˆg}tt |j¡ƒD]n}t |j|¡}t |¡}t |¡}t |¡}t |¡}t   t  |¡t  |¡¡dd…}|  t  |¡|f¡q|S)z¼ Returns the components of this name, as a sequence of 2-tuples. :return: The components of this name. :rtype: :py:class:`list` of ``name, value`` tuples. N)rÙrQrÚrrÛrÜrãrÝrÁrTrLrqror|rp) rxr rßràÚfnameZfvalr¶r{rÍrFrFrGÚget_componentsîs    ÿþzX509Name.get_components)rBrCrDrEryrÉrrÓr rær«rérêrÆr�rërarŠrr rírÊrFrFr³rGr(Es (( r(c@sºeZdZUdZdeeeededddœdd„Zee dœdd „ƒZ e j d e j d e jd iZejejeefed <edœdd„Zedœdd„Zedœdd„Zedœdd„Zedœdd„ZdS)r)z, An X.509 v3 certificate extension. Nr+)Ú type_nameÚcriticalrÍÚsubjectÚissuerrIcCs¶t d¡}t |tjtjtjtjd¡t |¡|durRt|tƒsJtdƒ‚|j |_ |durtt|tƒsltdƒ‚|j |_ |r€d|}t  tj|||¡}|tjkr¢t ƒt |tj¡|_dS)aÝ Initializes an X509 extension. :param type_name: The name of the type of extension_ to create. :type type_name: :py:data:`bytes` :param bool critical: A flag indicating whether this is a critical extension. :param value: The OpenSSL textual representation of the extension's value. :type value: :py:data:`bytes` :param subject: Optional X509 certificate to use as subject. :type subject: :py:class:`X509` :param issuer: Optional X509 certificate to use as issuer. :type issuer: :py:class:`X509` .. _extension: https://www.openssl.org/docs/manmaster/man5/ x509v3_config.html#STANDARD-EXTENSIONS z X509V3_CTX*rNzissuer must be an X509 instancez subject must be an X509 instances critical,)rTrUrQZX509V3_set_ctxrXZX509V3_set_ctx_nodbr`r+rbÚ_x509Ú issuer_certZ subject_certZX509V3_EXT_nconfr¦rYÚX509_EXTENSION_freeÚ _extension)rxrîrïrÍrðrñÚctxÚ extensionrFrFrGrys"     zX509Extension.__init__rucCst t |j¡¡SrP)rQrÝÚX509_EXTENSION_get_objectrõrwrFrFrGrÃSs ÿzX509Extension._nidZemailZDNSZURIÚ _prefixesc CsÒt dt |j¡¡}t |tj¡}g}tt |¡ƒD]’}t  ||¡}z|j |j }Wn8t yŒt ƒ}t ||¡| t|ƒ d¡¡Yq40t |jjj|jjj¡dd… d¡}| |d|¡q4d |¡S)NzGENERAL_NAMES*rÐú:z, )rTrnrQZX509V3_EXT_d2irõrYZGENERAL_NAMES_freerÙZsk_GENERAL_NAME_numZsk_GENERAL_NAME_valuerùr™ÚKeyErrorr[ZGENERAL_NAME_printr|r]rÂrLÚdZia5rZÚlengthÚjoin)rxÚnamesÚpartsrßr{ZlabelrNrÍrFrFrGÚ_subjectAltNameString_s( ÿ   ÿþz#X509Extension._subjectAltNameStringcCsFtj|jkr| ¡Stƒ}t ||jdd¡}t|dkƒt|ƒ  d¡S)zF :return: a nice text representation of the extension rrÐ) rQZNID_subject_alt_namerÃrr[ÚX509V3_EXT_printrõrWr]rÂ)rxrNÚ print_resultrFrFrGÚ__str__us   zX509Extension.__str__cCs t |j¡S)zk Returns the critical field of this X.509 extension. :return: The critical field. )rQZX509_EXTENSION_get_criticalrõrwrFrFrGÚ get_critical‚szX509Extension.get_criticalcCs<t |j¡}t |¡}t |¡}|tjkr4t |¡SdSdS)zü Returns the short type name of this X.509 extension. The result is a byte string such as :py:const:`b"basicConstraints"`. :return: The short type name. :rtype: :py:data:`bytes` .. versionadded:: 0.12 sUNDEFN)rQrørõrÝrÁrTrXrp)rxÚobjr¶ÚbufrFrFrGÚget_short_nameŠs     zX509Extension.get_short_namecCs@t |j¡}t d|¡}t |¡}t |¡}t ||¡dd…S)zÍ Returns the data of the X509 extension, encoded as ASN.1. :return: The ASN.1 encoded data of this X509 extension. :rtype: :py:data:`bytes` .. versionadded:: 0.12 rlN)rQÚX509_EXTENSION_get_datarõrTrnrqrorL)rxZ octet_resultrrZ char_resultÚ result_lengthrFrFrGÚget_data s    zX509Extension.get_data)NN)rBrCrDrErar«r ryÚpropertyrrÃrQZ GEN_EMAILZGEN_DNSZGEN_URIrùÚtypingÚClassVarÚDictr�rÉÚ__annotations__rrrrr rFrFrFrGr) s,  úù Eý r)zZX509Extension support in pyOpenSSL is deprecated. You should use the APIs in cryptography.rÅc@sÖeZdZdZddœdd„Zejdœdd„Zeejddœd d „ƒZ e dd œd d „Z e dœdd„Z e ddœdd„Ze dœdd„Zedœdd„Zeeddœdd„Zeedœdd„Ze eddœdd„Ze ed œdd „ZdS)!r*z0 An X.509 certificate signing requests. NrucCs&t ¡}t |tj¡|_| d¡dSrç)rQZ X509_REQ_newrTrYÚ X509_REQ_freeÚ_reqÚ set_version)rxÚreqrFrFrGryÂszX509Req.__init__cCsddlm}tt|ƒ}||ƒS)z® Export as a ``cryptography`` certificate signing request. :rtype: ``cryptography.x509.CertificateSigningRequest`` .. versionadded:: 17.1.0 r)Úload_der_x509_csr)Úcryptography.x509rr:r )rxrrŠrFrFrGÚto_cryptographyÈs  zX509Req.to_cryptography)Ú crypto_reqrIcCs6t|tjƒstdƒ‚ddlm}| |j¡}tt |ƒS)a Construct based on a ``cryptography`` *crypto_req*. :param crypto_req: A ``cryptography`` X.509 certificate signing request :type crypto_req: ``cryptography.x509.CertificateSigningRequest`` :rtype: X509Req .. versionadded:: 17.1.0 z%Must be a certificate signing requestr©r�) r`rÚCertificateSigningRequestrbrˆr�r•r–r;r )r—rr�rŠrFrFrGÚfrom_cryptographyÖs    zX509Req.from_cryptography©r…rIcCs t |j|j¡}t|dkƒdS)zµ Set the public key of the certificate signing request. :param pkey: The public key to use. :type pkey: :py:class:`PKey` :return: ``None`` rœN)rQZX509_REQ_set_pubkeyrr‚rW©rxr…rdrFrFrGÚ set_pubkeyìs zX509Req.set_pubkeycCsDt t¡}t |j¡|_t|jtjkƒt  |jtj ¡|_d|_ |S)z‹ Get the public key of the certificate signing request. :return: The public key. :rtype: :py:class:`PKey` T) r%Ú__new__rQZX509_REQ_get_pubkeyrr‚rWrTrXrYr�r‰r„rFrFrGÚ get_pubkeyøs  zX509Req.get_pubkey©ÚversionrIcCs@t|tƒstdƒ‚|dkr"tdƒ‚t |j|¡}t|dkƒdS)z± Set the version subfield (RFC 2986, section 4.1) of the certificate request. :param int version: The version number. :return: ``None`` zversion must be an intrz9Invalid version. The only valid version for X509Req is 0.rœN)r`r�rbrcrQZX509_REQ_set_versionrrW)rxr"rdrFrFrGrs ÿzX509Req.set_versioncCs t |j¡S)z¿ Get the version subfield (RFC 2459, section 4.1.2.1) of the certificate request. :return: The value of the version subfield. :rtype: :py:class:`int` )rQZX509_REQ_get_versionrrwrFrFrGÚ get_versionszX509Req.get_versioncCs2t t¡}t |j¡|_t|jtjkƒ||_ |S)aÝ Return the subject of this certificate signing request. This creates a new :class:`X509Name` that wraps the underlying subject name field on the certificate signing request. Modifying it will modify the underlying signing request, and will have the effect of modifying any other :class:`X509Name` that refers to this subject. :return: The subject of this certificate signing request. :rtype: :class:`X509Name` ) r(rrQZX509_REQ_get_subject_namerrrWrTrXÚ_ownerr}rFrFrGÚ get_subject!s zX509Req.get_subject©Ú extensionsrIcCslt ¡}t|tjkƒt |tj¡}|D]$}t|tƒs>t dƒ‚t  ||j ¡q(t  |j |¡}t|dkƒdS)z× Add extensions to the certificate signing request. :param extensions: The X.509 extensions to add. :type extensions: iterable of :py:class:`X509Extension` :return: ``None`` ú+One of the elements is not an X509ExtensionrœN)rQZsk_X509_EXTENSION_new_nullrWrTrXrYZsk_X509_EXTENSION_freer`Ú_X509ExtensionInternalrcZsk_X509_EXTENSION_pushrõZX509_REQ_add_extensionsr)rxr'ÚstackÚextrárFrFrGÚadd_extensions7s  zX509Req.add_extensionscCsng}t |j¡}t |dd„¡}tt |¡ƒD]:}t t¡}t  t  ||¡¡}t |tj ¡|_ |  |¡q.|S)zé Get X.509 extensions in the certificate signing request. :return: The X.509 extensions in this request. :rtype: :py:class:`list` of :py:class:`X509Extension` objects. .. versionadded:: 0.15 cSst |t tjd¡¡S)Nrô)rQZsk_X509_EXTENSION_pop_freerTZ addressofZ _original_lib)ÚxrFrFrGÚ]s þz(X509Req.get_extensions..)rQZX509_REQ_get_extensionsrrTrYrÙZsk_X509_EXTENSION_numr)rÚX509_EXTENSION_dupZsk_X509_EXTENSION_valuerôrõr|)rxZextsZnative_exts_objrßr+r÷rFrFrGÚget_extensionsPs  þ  ÿ zX509Req.get_extensions©r…ÚdigestrIcCs^|jrtdƒ‚|jstdƒ‚t t|ƒ¡}|tjkrd?„Z'ee&dd@œdAdB„Z(e&dœdCdD„Z)e&ddEœdFdG„Z*e&dœdHdI„Z+e&ddJœdKdL„Z,e dœdMdN„Z-e.e/ddOœdPdQ„Z0e e/dRœdSdT„Z1dS)Ur+z An X.509 certificate. NrucCs:t ¡}t|tjkƒt |tj¡|_tƒ|_ tƒ|_ dSrP) rQZX509_newrWrTrXrYÚ X509_freeròrtÚ_issuer_invalidatorÚ_subject_invalidator)rxrrFrFrGryŸs z X509.__init__)rrIcCs.| |¡}t |tj¡|_tƒ|_tƒ|_|SrP) rrTrYrQr;ròrtr<r=)r—rÚcertrFrFrGÚ_from_raw_x509_ptr§s  zX509._from_raw_x509_ptrcCsddlm}tt|ƒ}||ƒS)z� Export as a ``cryptography`` certificate. :rtype: ``cryptography.x509.Certificate`` .. versionadded:: 17.1.0 r)Úload_der_x509_certificate)rr@r1r )rxr@rŠrFrFrGr¯s  zX509.to_cryptography)Ú crypto_certrIcCs6t|tjƒstdƒ‚ddlm}| |j¡}tt |ƒS)zü Construct based on a ``cryptography`` *crypto_cert*. :param crypto_key: A ``cryptography`` X.509 certificate. :type crypto_key: ``cryptography.x509.Certificate`` :rtype: X509 .. versionadded:: 17.1.0 zMust be a certificaterr) r`rÚ Certificaterbrˆr�r•r–r0r )r—rAr�rŠrFrFrGr¼s   zX509.from_cryptographyr!cCs,t|tƒstdƒ‚tt |j|¡dkƒdS)a  Set the version number of the certificate. Note that the version value is zero-based, eg. a value of 0 is V1. :param version: The version number of the certificate. :type version: :py:class:`int` :return: ``None`` zversion must be an integerrœN)r`r�rbrWrQZX509_set_versionrò©rxr"rFrFrGrÐs zX509.set_versioncCs t |j¡S)z˜ Return the version number of the certificate. :return: The version number of the certificate. :rtype: :py:class:`int` )rQZX509_get_versionròrwrFrFrGr#ßszX509.get_versioncCsFt t¡}t |j¡|_|jtjkr*tƒt  |jtj ¡|_d|_ |S)z{ Get the public key of the certificate. :return: The public key. :rtype: :py:class:`PKey` T) r%rrQÚX509_get_pubkeyròr‚rTrXr¦rYr�r‰r„rFrFrGr ès  zX509.get_pubkeyrcCs2t|tƒstdƒ‚t |j|j¡}t|dkƒdS)z¥ Set the public key of the certificate. :param pkey: The public key. :type pkey: :py:class:`PKey` :return: :py:data:`None` r:rœN)r`r%rbrQZX509_set_pubkeyròr‚rWrrFrFrGr÷s zX509.set_pubkeyr1cCspt|tƒstdƒ‚|jr tdƒ‚|js.tdƒ‚t t|ƒ¡}|t j krNtdƒ‚t  |j |j |¡}t|dkƒdS)a Sign the certificate with this key and digest type. :param pkey: The key to sign with. :type pkey: :py:class:`PKey` :param digest: The name of the message digest to use. :type digest: :py:class:`str` :return: :py:data:`None` r:zKey only has public partr4r5rN)r`r%rbr‰rcrƒrQr6rÖrTrXZ X509_signròr‚rW)rxr…r2Zevp_mdr9rFrFrGr<s  z X509.signcCsZt |j¡}t d¡}t |tjtj|¡t |d¡}|tjkrJt dƒ‚t  t  |¡¡S)zþ Return the signature algorithm used in the certificate. :return: The name of the algorithm. :rtype: :py:class:`bytes` :raises ValueError: If the signature algorithm is undefined. .. versionadded:: 0.13 zASN1_OBJECT **rzUndefined signature algorithm) rQZX509_get0_tbs_sigalgròrTrUZX509_ALGOR_get0rXrÝr×rcrpZ OBJ_nid2ln)rxZsig_algZalgr¶rFrFrGÚget_signature_algorithm"s   zX509.get_signature_algorithm)Ú digest_namerIcCs„t t|ƒ¡}|tjkr tdƒ‚t dtj¡}t dd¡}t|ƒ|d<t  |j |||¡}t |dkƒd  dd„t  ||d¡Dƒ¡S) a5 Return the digest of the X509 object. :param digest_name: The name of the digest algorithm to use. :type digest_name: :py:class:`str` :return: The digest of the object, formatted as :py:const:`b":"`-delimited hex pairs. :rtype: :py:class:`bytes` r5úunsigned char[]zunsigned int[]rœró:cSsg|]}t|ƒ ¡‘qSrF)rÚupper)r·ZchrFrFrGÚ NsÿzX509.digest..)rQr6rÖrTrXrcrUZEVP_MAX_MD_SIZErVZ X509_digestròrWrþrL)rxrFr2r\r Z digest_resultrFrFrGr25s     ÿ þÿz X509.digestcCs t |j¡S)zƒ Return the hash of the X509 subject. :return: The hash of the subject. :rtype: :py:class:`bytes` )rQZX509_subject_name_hashròrwrFrFrGÚsubject_name_hashTszX509.subject_name_hash)ÚserialrIcCsÌt|tƒstdƒ‚t|ƒdd…}| d¡}t d¡}t ||¡}|dtj krpt  t  |j ¡|¡}|rÈt ƒnXt |dtj ¡}t |d¡|tj kr t ƒt |tj¡}t |j |¡}t|dkƒdS)z± Set the serial number of the certificate. :param serial: The new serial number. :type serial: :py:class:`int` :return: :py:data`None` zserial must be an integeréNrÀúBIGNUM**rrœ)r`r�rbÚhexrÞrTrUrQÚ BN_hex2bnrXZASN1_INTEGER_setÚX509_get_serialNumberròr¦ÚBN_to_ASN1_INTEGERrŸrYÚASN1_INTEGER_freeZX509_set_serialNumberrW)rxrLÚ hex_serialZhex_serial_bytesÚ bignum_serialZ small_serialrdÚ asn1_serialrFrFrGÚset_serial_number]s&     ÿ zX509.set_serial_numberc Cs‚t |j¡}t |tj¡}zVt |¡}z0t |¡}t|dƒ}|Wt  |¡Wt  |¡St  |¡0Wt  |¡n t  |¡0dS)zx Return the serial number of this certificate. :return: The serial number. :rtype: int éN) rQrQròZASN1_INTEGER_to_BNrTrXZ BN_bn2hexrpr�rärŸ)rxrVrUrTZhexstring_serialrLrFrFrGÚget_serial_number„s     þ üzX509.get_serial_number)ÚamountrIcCs.t|tƒstdƒ‚t |j¡}t ||¡dS)zÍ Adjust the time stamp on which the certificate stops being valid. :param int amount: The number of seconds by which to adjust the timestamp. :return: ``None`` úamount must be an integerN)r`r�rbrQÚX509_getm_notAfterròÚX509_gmtime_adj)rxrZZnotAfterrFrFrGÚgmtime_adj_notAfter˜s  zX509.gmtime_adj_notAftercCs.t|tƒstdƒ‚t |j¡}t ||¡dS)z½ Adjust the timestamp on which the certificate starts being valid. :param amount: The number of seconds by which to adjust the timestamp. :return: ``None`` r[N)r`r�rbrQÚX509_getm_notBeforeròr])rxrZZ notBeforerFrFrGÚgmtime_adj_notBefore¦s  zX509.gmtime_adj_notBeforecCsT| ¡}|durtdƒ‚| d¡}tj |d¡}tjj}tj |¡jdd�}||kS)z¡ Check whether the certificate has expired. :return: ``True`` if the certificate has expired, ``False`` otherwise. :rtype: bool NzUnable to determine notAfterrÐz %Y%m%d%H%M%SZ)Ztzinfo) Ú get_notAfterrcrÂÚdatetimeÚstrptimeÚtimezoneZutcZnowÚreplace)rxZ time_bytesZ time_stringZ not_afterZUTCZutcnowrFrFrGÚ has_expired³s zX509.has_expired)ÚwhichrIcCst||jƒƒSrP)rsrò)rxrgrFrFrGÚ_get_boundary_timeÄszX509._get_boundary_timecCs | tj¡S)a  Get the timestamp at which the certificate starts being valid. The timestamp is formatted as an ASN.1 TIME:: YYYYMMDDhhmmssZ :return: A timestamp string, or ``None`` if there is none. :rtype: bytes or NoneType )rhrQr_rwrFrFrGÚ get_notBeforeÇs zX509.get_notBefore.)rgr_rIcCst||jƒ|ƒSrP)rerò)rxrgr_rFrFrGÚ_set_boundary_timeÔszX509._set_boundary_timerfcCs| tj|¡S)zî Set the timestamp at which the certificate starts being valid. The timestamp is formatted as an ASN.1 TIME:: YYYYMMDDhhmmssZ :param bytes when: A timestamp string. :return: ``None`` )rjrQr_©rxr_rFrFrGÚ set_notBeforeÙs zX509.set_notBeforecCs | tj¡S)a  Get the timestamp at which the certificate stops being valid. The timestamp is formatted as an ASN.1 TIME:: YYYYMMDDhhmmssZ :return: A timestamp string, or ``None`` if there is none. :rtype: bytes or NoneType )rhrQr\rwrFrFrGraæs zX509.get_notAftercCs| tj|¡S)zí Set the timestamp at which the certificate stops being valid. The timestamp is formatted as an ASN.1 TIME:: YYYYMMDDhhmmssZ :param bytes when: A timestamp string. :return: ``None`` )rjrQr\rkrFrFrGÚ set_notAfterós zX509.set_notAftercCs0t t¡}||jƒ|_t|jtjkƒ||_|SrP)r(rròrrWrTrXr$)rxrgr{rFrFrGÚ _get_names   zX509._get_name)rgr{rIcCs0t|tƒstdƒ‚||j|jƒ}t|dkƒdS)Nzname must be an X509Namerœ)r`r(rbròrrW)rxrgr{rdrFrFrGÚ _set_name s zX509._set_namecCs| tj¡}|j |¡|S)a¥ Return the issuer of this certificate. This creates a new :class:`X509Name` that wraps the underlying issuer name field on the certificate. Modifying it will modify the underlying certificate, and will have the effect of modifying any other :class:`X509Name` that refers to this issuer. :return: The issuer of this certificate. :rtype: :class:`X509Name` )rnrQZX509_get_issuer_namer<r~r}rFrFrGÚ get_issuers  zX509.get_issuer)rñrIcCs| tj|¡|j ¡dS)zŸ Set the issuer of this certificate. :param issuer: The issuer. :type issuer: :py:class:`X509Name` :return: ``None`` N)rorQZX509_set_issuer_namer<r€)rxrñrFrFrGÚ set_issuer!s zX509.set_issuercCs| tj¡}|j |¡|S)a© Return the subject of this certificate. This creates a new :class:`X509Name` that wraps the underlying subject name field on the certificate. Modifying it will modify the underlying certificate, and will have the effect of modifying any other :class:`X509Name` that refers to this subject. :return: The subject of this certificate. :rtype: :class:`X509Name` )rnrQÚX509_get_subject_namer=r~r}rFrFrGr%-s  zX509.get_subject)rðrIcCs| tj|¡|j ¡dS)z£ Set the subject of this certificate. :param subject: The subject. :type subject: :py:class:`X509Name` :return: ``None`` N)rorQZX509_set_subject_namer=r€)rxrðrFrFrGÚ set_subject=s zX509.set_subjectcCs t |j¡S)z¯ Get the number of extensions on this certificate. :return: The number of extensions. :rtype: :py:class:`int` .. versionadded:: 0.12 )rQZX509_get_ext_countròrwrFrFrGÚget_extension_countIs zX509.get_extension_countr&cCs<|D]2}t|tƒstdƒ‚t |j|jd¡}|stƒqdS)zÍ Add extensions to the certificate. :param extensions: The extensions to add. :type extensions: An iterable of :py:class:`X509Extension` objects. :return: ``None`` r(rÑN)r`r)rcrQZ X509_add_extròrõr¦)rxr'r+rárFrFrGr,Ts  zX509.add_extensions)ÚindexrIcCsNt t¡}t |j|¡|_|jtjkr.tdƒ‚t  |j¡}t  |tj ¡|_|S)aÏ Get a specific extension of the certificate by index. Extensions on a certificate are kept in order. The index parameter selects which extension will be returned. :param int index: The index of the extension to retrieve. :return: The extension at the specified index. :rtype: :py:class:`X509Extension` :raises IndexError: If the extension index was out of bounds. .. versionadded:: 0.12 zextension index out of bounds) r)rrQZ X509_get_extròrõrTrXÚ IndexErrorr/rYrô)rxrur+r÷rFrFrGÚ get_extensionfs   zX509.get_extension)2rBrCrDrEryrªrr?rrBrrr�rr#r%r rrÉr<rarEr2rKrWrYr^r`r«rfr rhrirrjrlrarmr(rnrorprqr%rsrtrr)r,rwrFrFrFrGr+šsN   '  þ        þ r+c@sžeZdZUdZejZeed<ej Z eed<ej Z eed<ej Zeed<ejZeed<ejZeed<ejZeed<ejZeed <ejZeed <ejZeed <d S) r,a  Flags for X509 verification, used to change the behavior of :class:`X509Store`. See `OpenSSL Verification Flags`_ for details. .. _OpenSSL Verification Flags: https://www.openssl.org/docs/manmaster/man3/X509_VERIFY_PARAM_set_flags.html Ú CRL_CHECKÚ CRL_CHECK_ALLÚIGNORE_CRITICALÚ X509_STRICTÚALLOW_PROXY_CERTSÚ POLICY_CHECKÚEXPLICIT_POLICYÚ INHIBIT_MAPÚCHECK_SS_SIGNATUREÚ PARTIAL_CHAINN)rBrCrDrErQZX509_V_FLAG_CRL_CHECKrxr�rZX509_V_FLAG_CRL_CHECK_ALLryZX509_V_FLAG_IGNORE_CRITICALrzZX509_V_FLAG_X509_STRICTr{ZX509_V_FLAG_ALLOW_PROXY_CERTSr|ZX509_V_FLAG_POLICY_CHECKr}ZX509_V_FLAG_EXPLICIT_POLICYr~ZX509_V_FLAG_INHIBIT_MAPrZX509_V_FLAG_CHECK_SS_SIGNATUREr€ZX509_V_FLAG_PARTIAL_CHAINr�rFrFrFrGr,~s  r,c@s‚eZdZdZddœdd„Zeddœdd„Zed ej fdd œd d „Z e dd œdd„Z e j ddœdd„Zdeeeddœdd„ZdS)r-aº An X.509 store. An X.509 store is used to describe a context in which to verify a certificate. A description of a context may include a set of certificates to trust, a set of certificate revocation lists, verification flags and more. An X.509 store, being only a description, cannot be used by itself to verify a certificate. To carry out the actual verification process, see :class:`X509StoreContext`. NrucCst ¡}t |tj¡|_dSrP)rQZX509_STORE_newrTrYZX509_STORE_freeÚ_store©rxÚstorerFrFrGry£szX509Store.__init__©r>rIcCs0t|tƒstƒ‚t |j|j¡}t|dkƒdS)aÔ Adds a trusted certificate to this store. Adding a certificate with this method adds this certificate as a *trusted* certificate. :param X509 cert: The certificate to add to this store. :raises TypeError: If the certificate is not an :class:`X509`. :raises OpenSSL.crypto.Error: If OpenSSL was unhappy with your certificate. :return: ``None`` if the certificate was added successfully. rœN)r`r+rbrQZX509_STORE_add_certr‚ròrW)rxr>r¡rFrFrGÚadd_cert§s zX509Store.add_certÚ _CRLInternal)ÚcrlrIcCsŠt|tjƒrVddlm}t| |j¡ƒ}t  |t j ¡}|t j krFt ƒt   |tj¡}nt|tƒrh|j}ntdƒ‚tt |j|¡dkƒdS)a  Add a certificate revocation list to this store. The certificate revocation lists added to a store will only be used if the associated flags are configured to check certificate revocation lists. .. versionadded:: 16.1.0 :param crl: The certificate revocation list to add to this store. :type crl: ``Union[CRL, cryptography.x509.CertificateRevocationList]`` :return: ``None`` if the certificate revocation list was added successfully. rrzUCRL must be of type OpenSSL.crypto.CRL or cryptography.x509.CertificateRevocationListN)r`rÚCertificateRevocationListrˆr�r[r•r–rQÚd2i_X509_CRL_biorTrXr¦rYÚ X509_CRL_freer‡Ú_crlrbrWZX509_STORE_add_crlr‚)rxrˆr�rNZ openssl_crlrFrFrGÚadd_crl½s    ÿzX509Store.add_crl)ÚflagsrIcCstt |j|¡dkƒdS)aÒ Set verification flags to this store. Verification flags can be combined by oring them together. .. note:: Setting a verification flag sometimes requires clients to add additional information to the store, otherwise a suitable error will be raised. For example, in setting flags to enable CRL checking a suitable CRL must be added to the store otherwise an error will be raised. .. versionadded:: 16.1.0 :param int flags: The verification flags to set on this store. See :class:`X509StoreFlags` for available constants. :return: ``None`` if the verification flags were successfully set. rN)rWrQZX509_STORE_set_flagsr‚)rxrŽrFrFrGÚ set_flagsászX509Store.set_flags)Úvfy_timerIcCsFt ¡}t |tj¡}t |t | ¡¡¡t t  |j |¡dkƒdS)a¤ Set the time against which the certificates are verified. Normally the current time is used. .. note:: For example, you can determine if a certificate was valid at a given time. .. versionadded:: 17.0.0 :param datetime vfy_time: The verification time to set on this store. :return: ``None`` if the verification time was successfully set. rN) rQZX509_VERIFY_PARAM_newrTrYZX509_VERIFY_PARAM_freeZX509_VERIFY_PARAM_set_timeÚcalendarZtimegmZ timetuplerWZX509_STORE_set1_paramr‚)rxr�ZparamrFrFrGÚset_timeùs ÿzX509Store.set_time)ÚcafileÚcapathrIcCsN|durtj}nt|ƒ}|dur(tj}nt|ƒ}t |j||¡}|sJtƒdS)aˆ Let X509Store know where we can find trusted certificates for the certificate chain. Note that the certificates have to be in PEM format. If *capath* is passed, it must be a directory prepared using the ``c_rehash`` tool included with OpenSSL. Either, but not both, of *cafile* or *capath* may be ``None``. .. note:: Both *cafile* and *capath* may be set simultaneously. Call this method multiple times to add more than one location. For example, CA certificates, and certificate revocation list bundles may be passed in *cafile* in subsequent calls to this method. .. versionadded:: 20.0 :param cafile: In which file we can find the certificates (``bytes`` or ``unicode``). :param capath: In which directory we can find the certificates (``bytes`` or ``unicode``). :return: ``None`` if the locations were set successfully. :raises OpenSSL.crypto.Error: If both *cafile* and *capath* is ``None`` or the locations could not be set for any reason. N)rTrXÚ _path_bytesrQZX509_STORE_load_locationsr‚r¦)rxr“r”Z load_resultrFrFrGÚload_locationss!ÿzX509Store.load_locations)N)rBrCrDrEryr+r†rrr‰r�r�r�rbr’ÚStrOrBytesPathr r–rFrFrFrGr-•s  þ $ÿþr-cs0eZdZdZeeeeddœ‡fdd„ Z‡Z S)r.zù An exception raised when an error occurred while verifying a certificate using `OpenSSL.X509StoreContext.verify_certificate`. :ivar certificate: The certificate which caused verificate failure. :type certificate: :class:`X509` N)ÚmessageÚerrorsÚ certificaterIcstƒ |¡||_||_dSrP)r¯ryr™rš)rxr˜r™ršr³rFrGryLs zX509StoreContextError.__init__) rBrCrDrErÉrrr+ryrÊrFrFr³rGr.Cs þr.c@s¤eZdZdZdeeeeeddœdd„Ze eeeddœdd„ƒZ dd œd d „Z dd œd d „Z e d œdd„Zeddœdd„Zdd œdd„Zeed œdd„ZdS)r/a™ An X.509 store context. An X.509 store context is used to carry out the actual verification process of a certificate in a described context. For describing such a context, see :class:`X509Store`. :ivar _store_ctx: The underlying X509_STORE_CTX structure used by this instance. It is dynamically allocated and automatically garbage collected. :ivar _store: See the ``store`` ``__init__`` parameter. :ivar _cert: See the ``certificate`` ``__init__`` parameter. :ivar _chain: See the ``chain`` ``__init__`` parameter. :param X509Store store: The certificates which will be trusted for the purposes of any verifications. :param X509 certificate: The certificate to be verified. :param chain: List of untrusted certificates that may be used for building the certificate chain. May be ``None``. :type chain: :class:`list` of :class:`X509` N)r„ršÚchainrIcCs<t ¡}t |tj¡|_||_||_| |¡|_ |  ¡dSrP) rQZX509_STORE_CTX_newrTrYZX509_STORE_CTX_freeÚ _store_ctxr‚Ú_certÚ_build_certificate_stackÚ_chainÚ_init)rxr„ršr›Z store_ctxrFrFrGryjs  zX509StoreContext.__init__)Ú certificatesrIcCs¤tddœdd„}|dus$t|ƒdkr*tjSt ¡}t|tjkƒt ||¡}|D]N}t|t ƒsft dƒ‚tt  |j ¡dkƒt  ||j ¡dkrPt |j ¡tƒqP|S)N)ÚsrIcSs8tt |¡ƒD]}t ||¡}t |¡qt |¡dSrP)rÙrQÚ sk_X509_numÚ sk_X509_valuer;Ú sk_X509_free)r¢rßr-rFrFrGÚcleanup~s  z:X509StoreContext._build_certificate_stack..cleanuprz+One of the elements is not an X509 instance)rrVrTrXrQÚsk_X509_new_nullrWrYr`r+rbZ X509_up_refròÚ sk_X509_pushr;r¦)r¡r¦r*r>rFrFrGržzs   z)X509StoreContext._build_certificate_stackrucCs.t |j|jj|jj|j¡}|dkr*tƒdS)zÀ Set up the store context for a subsequent verification operation. Calling this method more than once without first calling :meth:`_cleanup` will leak memory. rN)rQZX509_STORE_CTX_initrœr‚r�ròrŸr¦©rxrirFrFrGr ˜s ÿzX509StoreContext._initcCst |j¡dS)z‰ Internally cleans up the store context. The store context can then be reused with a new call to :meth:`_init`. N)rQZX509_STORE_CTX_cleanuprœrwrFrFrGÚ_cleanup¥szX509StoreContext._cleanupcCsdt t t |j¡¡¡ d¡}t |j¡t |j¡|g}t |j¡}t  |¡}t   |¡}t |||ƒS)zú Convert an OpenSSL native context error failure into a Python exception. When a call to native OpenSSL X509_verify_cert fails, additional information about the failure can be obtained from the store context. rÐ) rTrprQZX509_verify_cert_error_stringZX509_STORE_CTX_get_errorrœrÂZX509_STORE_CTX_get_error_depthZX509_STORE_CTX_get_current_certZX509_dupr+r?r.)rxr˜r™ròr�ÚpycertrFrFrGÚ_exception_from_context­s ÿÿü  ý   z(X509StoreContext._exception_from_context)r„rIcCs ||_dS)zÖ Set the context's X.509 store. .. versionadded:: 0.15 :param X509Store store: The store description which will be used for the purposes of any *future* verifications. N)r‚rƒrFrFrGÚ set_storeÆs zX509StoreContext.set_storecCs8| ¡| ¡t |j¡}| ¡|dkr4| ¡‚dS)a" Verify a certificate in a context. .. versionadded:: 0.15 :raises X509StoreContextError: If an error occurred when validating a certificate in the context. Sets ``certificate`` attribute to indicate which certificate caused the error. rN)rªr rQÚX509_verify_certrœr¬r©rFrFrGÚverify_certificateÑs  z#X509StoreContext.verify_certificatecCsª| ¡| ¡t |j¡}|dkr4| ¡| ¡‚t |j¡}t|tj kƒg}t t  |¡ƒD]2}t  ||¡}t|tj kƒt  |¡}| |¡q`t |¡| ¡|S)aR Verify a certificate in a context and return the complete validated chain. :raises X509StoreContextError: If an error occurred when validating a certificate in the context. Sets ``certificate`` attribute to indicate which certificate caused the error. .. versionadded:: 20.0 r)rªr rQr®rœr¬ZX509_STORE_CTX_get1_chainrWrTrXrÙr£r¤r+r?r|r¥)rxriZ cert_stackr rßr>r«rFrFrGÚget_verified_chainçs"      z#X509StoreContext.get_verified_chain)N)rBrCrDrEr-r+r r ryÚ staticmethodržr rªr.r¬r­r¯rr°rFrFrFrGr/Ts$ü û  þ  r/)r™rLrIcCsvt|tƒr| d¡}t|ƒ}|tkrrIcCsntƒ}|tkrt ||j¡}n<|tkr6t ||j¡}n$|tkrRt ||jdd¡}nt dƒ‚t |dkƒt |ƒS)a Dump the certificate *cert* into a buffer string encoded with the type *type*. :param type: The file type (one of FILETYPE_PEM, FILETYPE_ASN1, or FILETYPE_TEXT) :param cert: The certificate to dump :return: The buffer with the dumped certificate in rúCtype argument must be FILETYPE_PEM, FILETYPE_ASN1, or FILETYPE_TEXTrœ) r[rrQZPEM_write_bio_X509ròr Z i2d_X509_bior!Z X509_print_exrcrWr])r™r>rNÚ result_coderFrFrGr1,s ÿ r1)r™r…rIcCsPtƒ}|tkrtj}n|tkr&tj}ntdƒ‚|||jƒ}|dkrHtƒt |ƒS)zú Dump a public key to a buffer. :param type: The file type (one of :data:`FILETYPE_PEM` or :data:`FILETYPE_ASN1`). :param PKey pkey: The public key to dump :return: The buffer with the dumped key in it. :rtype: bytes r²rœ) r[rrQZPEM_write_bio_PUBKEYr Zi2d_PUBKEY_biorcr‚r¦r])r™r…rNZ write_bior´rFrFrGr2Hs  r2)r™r…ÚcipherÚ passphraserIc Cstƒ}t|tƒstdƒ‚|durR|dur0tdƒ‚t t|ƒ¡}|tjkrXt dƒ‚ntj}t ||ƒ}|t kr’t  ||j |tjd|j|j¡}| ¡nh|tkrªt ||j ¡}nP|tkròt |j ¡tjkrÌtdƒ‚t t |j ¡tj¡}t ||d¡}nt dƒ‚t|dkƒt|ƒS)a… Dump the private key *pkey* into a buffer string encoded with the type *type*. Optionally (if *type* is :const:`FILETYPE_PEM`) encrypting it using *cipher* and *passphrase*. :param type: The file type (one of :const:`FILETYPE_PEM`, :const:`FILETYPE_ASN1`, or :const:`FILETYPE_TEXT`) :param PKey pkey: The PKey to dump :param cipher: (optional) if encrypted PEM format, the cipher to use :param passphrase: (optional) if encrypted PEM format, this can be either the passphrase to use, or a callback for providing the passphrase. :return: The buffer with the dumped key in :rtype: bytes zpkey must be a PKeyNzDif a value is given for cipher one must also be given for passphrasezInvalid cipher namerz-Only RSA keys are supported for FILETYPE_TEXTr³)r[r`r%rbrQZEVP_get_cipherbynamerÖrTrXrcÚ_PassphraseHelperrZPEM_write_bio_PrivateKeyr‚ÚcallbackÚ callback_argsÚraise_if_problemr Zi2d_PrivateKey_bior!r¨r£rYr¤r¥Z RSA_printrWr]) r™r…rµr¶rNZ cipher_objÚhelperr´rrFrFrGr3asH ÿ   ù ÿ r3c@sÂeZdZUdZgd¢Zejejee d<ddœdd„Z eddœd d „Z edœd d „Z ddœd d„Z eeddœdd„Zeedœdd„Zeedœdd„Zeddœdd„Zeedœdd„ZdS)r4z# A certificate revocation. )s unspecifieds keyCompromises CACompromisesaffiliationChangeds supersededscessationOfOperationscertificateHoldÚ _crl_reasonsNrucCst ¡}t |tj¡|_dSrP)rQZX509_REVOKED_newrTrYÚX509_REVOKED_freeÚ_revoked)rxÚrevokedrFrFrGryºszRevoked.__init__)Úhex_strrIcCsft t ¡tj¡}t d¡}||d<t ||¡}|s.rrœ)rÆr`rarbrÉrer¼rurQZASN1_ENUMERATED_newrWrTrXrYZASN1_ENUMERATED_freeZASN1_ENUMERATED_setZX509_REVOKED_add1_ext_i2dr¾rÅ)rxrÇZ reason_codeZnew_reason_extrdrárFrFrGÚ set_reasonñs     ÿzRevoked.set_reasoncCs†tt |j¡ƒD]p}t |j|¡}t |¡}t |¡tjkrtƒ}t  ||dd¡}|stt  |t  |¡¡}t |dkƒt |ƒSqdS)a  Get the reason of this revocation. :return: The reason, or ``None`` if there is none. :rtype: bytes or NoneType .. seealso:: :meth:`all_reasons`, which gives you a list of all supported reasons this method might return. rN)rÙrQrÃr¾rÄrørÝrÅr[rZM_ASN1_OCTET_STRING_printr rWr])rxrßr+rrNrrFrFrGÚ get_reason s   ÿ zRevoked.get_reasoncCs|jdd…S)a Return a list of all the supported reason strings. This list is a copy; modifying it does not change the supported reason strings. :return: A list of reason strings. :rtype: :class:`list` of :class:`bytes` N)r¼rwrFrFrGÚ all_reasons2 s zRevoked.all_reasonsrfcCs&t|ƒ}t |j|¡}t|dkƒdS)z¡ Set the revocation timestamp. :param bytes when: The timestamp of the revocation, as ASN.1 TIME. :return: ``None`` rœN)rjrQZX509_REVOKED_set_revocationDater¾rW)rxr_ZrevocationDaterirFrFrGÚ set_rev_date> s ÿzRevoked.set_rev_datecCst |j¡}t|ƒS)z‡ Get the revocation timestamp. :return: The timestamp of the revocation, as ASN.1 TIME. :rtype: bytes )rQZ X509_REVOKED_get0_revocationDater¾rs)rxZdtrFrFrGÚ get_rev_dateL s zRevoked.get_rev_date)rBrCrDrEr¼r rrrarryrÁrÂrÆr rËrÌrÍrÎrÏrFrFrFrGr4¦s   % r4zPCRL support in pyOpenSSL is deprecated. You should use the APIs in cryptography.c@sàeZdZdZddœdd„Zejdœdd„Zeejdd œd d „ƒZ e e e d fdœd d„Z e ddœdd„Zedœdd„Zeddœdd„Zeddœdd„Zeddœdd„Zeeeddœdd„Zedefeeeeeed œd!d"„ZdS)#r5z( A certificate revocation list. NrucCst ¡}t |tj¡|_dSrP)rQZ X509_CRL_newrTrYr‹rŒ)rxrˆrFrFrGryi sz CRL.__init__cCsddlm}tt|ƒ}||ƒS)z– Export as a ``cryptography`` CRL. :rtype: ``cryptography.x509.CertificateRevocationList`` .. versionadded:: 17.1.0 r)Úload_der_x509_crl)rrÐÚ_dump_crl_internalr )rxrÐrŠrFrFrGrm s  zCRL.to_cryptographyr‡)Ú crypto_crlrIcCs6t|tjƒstdƒ‚ddlm}| |j¡}tt |ƒS)a Construct based on a ``cryptography`` *crypto_crl*. :param crypto_crl: A ``cryptography`` certificate revocation list :type crypto_crl: ``cryptography.x509.CertificateRevocationList`` :rtype: CRL .. versionadded:: 17.1.0 z%Must be a certificate revocation listrr) r`rr‰rbrˆr�r•r–Ú_load_crl_internalr )r—rÒr�rŠrFrFrGrz s    zCRL.from_cryptography.cCsng}t |j¡}tt |¡ƒD]>}t ||¡}t |¡}t t¡}t   |tj ¡|_ |  |¡q|rjt|ƒSdS)aA Return the revocations in this certificate revocation list. These revocations will be provided by value, not by reference. That means it's okay to mutate them: it won't affect this CRL. :return: The revocations in this CRL. :rtype: :class:`tuple` of :class:`Revocation` N)rQZX509_CRL_get_REVOKEDrŒrÙZsk_X509_REVOKED_numZsk_X509_REVOKED_valueÚX509_REVOKED_dupÚ_RevokedInternalrrTrYr½r¾r|Útuple)rxÚresultsZ revoked_stackrßr¿Z revoked_copyZpyrevrFrFrGÚ get_revoked� s      zCRL.get_revoked)r¿rIcCs8t |j¡}t|tjkƒt |j|¡}t|dkƒdS)a9 Add a revoked (by value not reference) to the CRL structure This revocation will be added by value, not by reference. That means it's okay to mutate it after adding: it won't affect this CRL. :param Revoked revoked: The new revocation. :return: ``None`` rN)rQrÔr¾rWrTrXZX509_CRL_add0_revokedrŒ)rxr¿ÚcopyrárFrFrGÚ add_revoked¦ s zCRL.add_revokedcCsBt t |j¡¡}t|tjkƒt |tj¡}t   t ¡}||_ |S)zc Get the CRL's issuer. .. versionadded:: 16.1.0 :rtype: X509Name ) rQrËZX509_CRL_get_issuerrŒrWrTrXrYrÌr(rr)rxZ_issuerrñrFrFrGrp· s  zCRL.get_issuerr!cCstt |j|¡dkƒdS)z— Set the CRL version. .. versionadded:: 16.1.0 :param int version: The version of the CRL. :return: ``None`` rN)rWrQZX509_CRL_set_versionrŒrCrFrFrGrÆ s zCRL.set_versionrfcCs&t|ƒ}t |j|¡}t|dkƒdS)zô Set when the CRL was last updated. The timestamp is formatted as an ASN.1 TIME:: YYYYMMDDhhmmssZ .. versionadded:: 16.1.0 :param bytes when: A timestamp string. :return: ``None`` rœN)rjrQÚX509_CRL_set1_lastUpdaterŒrW)rxr_Z lastUpdaterirFrFrGÚset_lastUpdateÑ s zCRL.set_lastUpdatecCs&t|ƒ}t |j|¡}t|dkƒdS)zø Set when the CRL will next be updated. The timestamp is formatted as an ASN.1 TIME:: YYYYMMDDhhmmssZ .. versionadded:: 16.1.0 :param bytes when: A timestamp string. :return: ``None`` rœN)rjrQÚX509_CRL_set1_nextUpdaterŒrW)rxr_Z nextUpdaterirFrFrGÚset_nextUpdateâ s zCRL.set_nextUpdate)róÚ issuer_keyr2rIcCs\t |¡}t|tjkƒt |jt |j¡¡t  |j¡t  |j|j |¡}t|dkƒdS)a; Sign the CRL. Signing a CRL enables clients to associate the CRL itself with an issuer. Before a CRL is meaningful to other OpenSSL functions, it must be signed by an issuer. This method implicitly sets the issuer's name based on the issuer certificate and private key used to sign the CRL. .. versionadded:: 16.1.0 :param X509 issuer_cert: The issuer's certificate. :param PKey issuer_key: The issuer's private key. :param bytes digest: The digest method to sign the CRL with. rN) rQr6rWrTrXÚX509_CRL_set_issuer_namerŒrrròZ X509_CRL_sortÚ X509_CRL_signr‚)rxrórßr2r8r rFrFrGr<ó s ÿ zCRL.signéd)r>rÇr™Údaysr2rIc CsDt|tƒstdƒ‚t|tƒs$tdƒ‚t|tƒs6tdƒ‚|turFtdƒ‚t |¡}|tj krbt dƒ‚t  ¡}t |tj kƒt  |tj¡}t |d¡}t |tj kƒt |j|¡}t |dkƒt ||dd d ¡}t |tj kƒt |j|¡}t |dkƒt |jt |j¡¡}t |dkƒt |j|j|¡} | �s:tƒt||ƒS) aó Export the CRL as a string. :param X509 cert: The certificate used to sign the CRL. :param PKey key: The key used to sign the CRL. :param int type: The export format, either :data:`FILETYPE_PEM`, :data:`FILETYPE_ASN1`, or :data:`FILETYPE_TEXT`. :param int days: The number of days until the next update of this CRL. :param bytes digest: The name of the message digest to use (eg ``b"sha256"``). :rtype: bytes úcert must be an X509 instancezkey must be a PKey instancer›zdigest must be providedr5rrœéé<)r`r+rbr%r�Ú _UNSPECIFIEDrQr6rTrXrcrgrWrYrhr]rÛrŒrÝràrrròrár‚r¦rÑ) rxr>rÇr™rãr2r8Zsometimerir9rFrFrGÚexport s<        ÿ z CRL.export)rBrCrDrEryrr‰rrªrr r rÕrØrÚr(rpr�rrarÜrÞr+r%r<rrçrèrFrFrFrGr5d s2 þ úùr5c@sÔeZdZdZddœdd„Zeedœdd„Zeddœd d „Zee dœd d „Z e dd œdd„Z ee edfdœdd„Z eeeddœdd„Zeeddœdd„Zeedœdd„Zd eeeeedœdd„ZdS)!r6z A PKCS #12 archive. NrucCsd|_d|_d|_d|_dSrP)r‚r�Ú_cacertsÚ _friendlynamerwrFrFrGry^ szPKCS12.__init__cCs|jS)z¾ Get the certificate in the PKCS #12 structure. :return: The certificate, or :py:const:`None` if there is none. :rtype: :py:class:`X509` or :py:const:`None` )r�rwrFrFrGÚget_certificated szPKCS12.get_certificater…cCst|tƒstdƒ‚||_dS)zà Set the certificate in the PKCS #12 structure. :param cert: The new certificate, or :py:const:`None` to unset it. :type cert: :py:class:`X509` or :py:const:`None` :return: ``None`` räN)r`r+rbr�)rxr>rFrFrGÚset_certificatem s zPKCS12.set_certificatecCs|jS)zª Get the private key in the PKCS #12 structure. :return: The private key, or :py:const:`None` if there is none. :rtype: :py:class:`PKey` )r‚rwrFrFrGÚget_privatekeyz szPKCS12.get_privatekeyrcCst|tƒstdƒ‚||_dS)zè Set the certificate portion of the PKCS #12 structure. :param pkey: The new private key, or :py:const:`None` to unset it. :type pkey: :py:class:`PKey` or :py:const:`None` :return: ``None`` r:N)r`r%rbr‚r„rFrFrGÚset_privatekeyƒ s zPKCS12.set_privatekey.cCs|jdurt|jƒSdS)a Get the CA certificates in the PKCS #12 structure. :return: A tuple with the CA certificates in the chain, or :py:const:`None` if there are none. :rtype: :py:class:`tuple` of :py:class:`X509` or :py:const:`None` N)rérÖrwrFrFrGÚget_ca_certificates� s  zPKCS12.get_ca_certificates)ÚcacertsrIcCs>|durd|_n*t|ƒ}|D]}t|tƒstdƒ‚q||_dS)a Replace or set the CA certificates within the PKCS12 object. :param cacerts: The new CA certificates, or :py:const:`None` to unset them. :type cacerts: An iterable of :py:class:`X509` or :py:const:`None` :return: ``None`` Nz)iterable must only contain X509 instances)réÚlistr`r+rb)rxrðr>rFrFrGÚset_ca_certificatesœ s  ÿzPKCS12.set_ca_certificatesrzcCs4|durd|_nt|tƒs*td|›d�ƒ‚||_dS)zâ Set the friendly name in the PKCS #12 structure. :param name: The new friendly name, or :py:const:`None` to unset. :type name: :py:class:`bytes` or :py:const:`None` :return: ``None`` Nz(name must be a byte string or None (not ú))rêr`rarbr}rFrFrGÚset_friendlyname± s   ÿzPKCS12.set_friendlynamecCs|jS)zÅ Get the friendly name in the PKCS# 12 structure. :returns: The friendly name, or :py:const:`None` if there is none. :rtype: :py:class:`bytes` or :py:const:`None` )rêrwrFrFrGÚget_friendlyname szPKCS12.get_friendlynameérœ)r¶ÚiterÚmaciterrIc Csútd|ƒ}|jdurtj}n0t ¡}t |tj¡}|jD]}t ||j ¡q8|durZtj}|j }|durntj}|j dur€tj}n|j j }|j durštj}n|j j }t  |||||tjtj||d¡ }|tjkrÒtƒt |tj¡}tƒ} t | |¡t| ƒS)a€ Dump a PKCS12 object as a string. For more information, see the :c:func:`PKCS12_create` man page. :param passphrase: The passphrase used to encrypt the structure. Unlike some other passphrase arguments, this *must* be a string, not a callback. :type passphrase: :py:data:`bytes` :param iter: Number of times to repeat the encryption step. :type iter: :py:data:`int` :param maciter: Number of times to repeat the MAC step. :type maciter: :py:data:`int` :return: The string representation of the PKCS #12 structure. :rtype: r¶Nr)Ú_text_to_bytes_and_warnrérTrXrQr§rYr¥r¨ròrêr‚r�Z PKCS12_createZ&NID_pbe_WithSHA1And3_Key_TripleDES_CBCr¦Z PKCS12_freer[Zi2d_PKCS12_bior]) rxr¶r÷rørðr>Z friendlynamer…Zpkcs12rNrFrFrGrèË sH     ö  z PKCS12.export)Nrörœ)rBrCrDrEryr r+rërìr%rírîr rïrròrarôrõr�rèrFrFrFrGr6Y s&      üûr6zTPKCS#12 support in pyOpenSSL is deprecated. You should use the APIs in cryptography.c@sleZdZdZddœdd„Zeeddœdd„Zeed œd d „Z e dœd d „Z edœdd„Z eddœdd„Z dS)r7z! A Netscape SPKI object. NrucCst ¡}t |tj¡|_dSrP)rQZNETSCAPE_SPKI_newrTrYZNETSCAPE_SPKI_freeÚ_spki)rxZspkirFrFrGry% szNetscapeSPKI.__init__r1cCs^|jrtdƒ‚|jstdƒ‚t t|ƒ¡}|tjkrsign() is deprecated. Use the equivilant APIs in cryptography.)r>Ú signaturerZr2rIcCs¬td|ƒ}t t|ƒ¡}|tjkr*tdƒ‚t |j¡}t |tjkƒt  |tj ¡}t  ¡}t  |tj ¡}t ||¡t ||t|ƒ¡t ||t|ƒ|¡}|dkr¨tƒdS)aŸ Verify the signature for a data string. :param cert: signing certificate (X509 object) corresponding to the private key which generated the signature. :param signature: signature returned by sign function :param data: data to be verified :param digest: message digest to use :return: ``None`` if the signature is correct, raise exception otherwise. .. versionadded:: 0.11 rZr5rœN)rùrQr6rÖrTrXrcrDròrWrYr�rrZEVP_VerifyInitZEVP_VerifyUpdaterVZEVP_VerifyFinalr¦)r>rrZr2r8r…rZ verify_resultrFrFrGr=€ s      ÿr=z@verify() is deprecated. Use the equivilant APIs in cryptography.)r™rˆrIcCsjtƒ}|tkrt ||j¡}n8|tkr6t ||j¡}n |tkrNt ||j¡}nt dƒ‚t |dkƒt |ƒS)a Dump a certificate revocation list to a buffer. :param type: The file type (one of ``FILETYPE_PEM``, ``FILETYPE_ASN1``, or ``FILETYPE_TEXT``). :param CRL crl: The CRL to dump. :return: The buffer with the CRL. :rtype: bytes r³rœ) r[rrQZPEM_write_bio_X509_CRLrŒr Zi2d_X509_CRL_bior!ZX509_CRL_printrcrWr])r™rˆrNrirFrFrGr>¯ s ÿ r>cCsŠt|tƒr| d¡}t|ƒ}|tkrrÑr?rÓrFrFrFrGÚsL    4        %ÿ   ) 6gD(ø ^g/<üû E2ø iø <ø Zû N%ý ü )#û þ &û ø ø