%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/certbot/_internal/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/certbot/_internal/__pycache__/account.cpython-312.pyc

�

M/�e29���dZddlZddlZddlZddlZddlZddlZddlmZddlm	Z	ddlm
Z
ddlmZddlmZddlm
Z
dd	lmZdd
lmZddlZddlZddlZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddl m!Z!ddl"m#Z#ddl"m$Z$ejJe&�Z'Gd�d�Z(Gd�dejR�Z*Gd�dejR�Z+y)z!Creates ACME accounts for server.�N)�Any)�Callable)�cast)�Dict)�List)�Mapping)�Optional)�
serialization)�fields)�messages)�ClientV2)�
configuration)�errors)�
interfaces)�util)�	constants)�
filesystem)�osc	��eZdZdZGd�dej
�Z	ddejdejde
dddfd	�Zede
fd
��Zde
fd�Zdedefd
�Zy)�Accountz�ACME protocol registration.

    :ivar .RegistrationResource regr: Registration Resource
    :ivar .JWK key: Authorized Account Key
    :ivar .Meta: Account metadata
    :ivar str id: Globally unique account identifier.

    c��eZdZUdZej
d�Zejed<e	jd�Zeed<e	jdd��Z
eed<y)�Account.Metaa�Account metadata

        :ivar datetime.datetime creation_dt: Creation date and time (UTC).
        :ivar str creation_host: FQDN of host, where account has been created.
        :ivar str register_to_eff: If not None, Certbot will register the provided
                                        email during the account registration.

        .. note:: ``creation_dt`` and ``creation_host`` are useful in
            cross-machine migration scenarios.

        �creation_dt�
creation_host�register_to_effT)�	omitemptyN)�__name__�
__module__�__qualname__�__doc__�acme_fields�rfc3339r�datetime�__annotations__�jose�fieldr�strr���;/usr/lib/python3/dist-packages/certbot/_internal/account.py�Metar-sS��
	�*=��)<�)<�]�)K��X�&�&�K�'�T�Z�Z��8�
�s�8�)�t�z�z�*;�t�L���Lr)r+N�regr�key�meta�returnc
��||_||_|�b|jtjj	t
j��jd��tj�d��n||_
	tj�}|j'|jjj)�j+t,j.j0t,j2j4���|j7�|_y#t$r5tjditt t"t$fddi���}Y��wxYw)	N)�tzr)�microsecond)rrr�usedforsecurityF)�encoding�format)�md5)r-r,r+r#�now�pytz�UTC�replace�socket�getfqdnr.�hashlibr6�
ValueError�newrrr'r�update�
public_key�public_bytesr
�Encoding�PEM�PublicFormat�SubjectPublicKeyInfo�	hexdigest�id)�selfr,r-r.�hashers     r*�__init__zAccount.__init__=s�������	�
&*�\�	�I�I� �)�)�-�-����-�:�B�B�q�B�Q� �.�.�*� �	�"�8<�		
�	�	_��[�[�]�F�	�
�
�d�h�h�l�l�-�-�/�<�<�"�+�+�/�/� �-�-�B�B�=�D�	
�
�"�"�$�����	_��[�[�^�$�w�s�C�x�/@�CT�V[�B\�*]�^�F�		_�s�;D�;E�Ec��djtj|jj�|jj
|jdd�S)z3Short account identification string, useful for UI.z
{1}@{0} ({2})N�)r5�	pyrfc3339�generater.rrrH�rIs r*�slugzAccount.slug\sL���%�%�i�&8�&8��I�I�!�!�'#�$(�I�I�$;�$;�T�W�W�R�a�[�J�	Jr)c��dj|jj|j|j|j
�S)Nz<{0}({1}, {2}, {3})>)r5�	__class__rr,rHr.rPs r*�__repr__zAccount.__repr__bs6��%�,�,��N�N�#�#�T�Y�Y�������D�	Dr)�otherc���t||j�xrO|j|jk(xr4|j|jk(xr|j|jk(S�N)�
isinstancerSr-r,r.)rIrUs  r*�__eq__zAccount.__eq__fsT���5�$�.�.�1�(����E�I�I�%�(�*.�)�)�u�z�z�*A�(��	�	�U�Z�Z�'�	)r)rW)rrrr r%�JSONObjectWithFieldsr+r�RegistrationResource�JWKr	rK�propertyr'rQrTr�boolrYr(r)r*rr#s����M�t�(�(�M�"+/�%�X�:�:�%����%���'�%�37�%�>�J�c�J��J�
D�#�D�)�C�)�D�)r)rc�h�eZdZdZddeeeefddfd�Zde	efd�Z
dededdfd	�Zd
edefd�Z
y)
�AccountMemoryStoragezIn-memory account storage.N�initial_accountsr/c�&�|�||_yi|_yrW)�accounts)rIras  r*rKzAccountMemoryStorage.__init__os��,<�,H�(��
�b��
r)c�H�t|jj��SrW)�listrc�valuesrPs r*�find_allzAccountMemoryStorage.find_allrs���D�M�M�(�(�*�+�+r)�account�clientc��|j|jvr tjd|j�||j|j<y)NzOverwriting account: %s)rHrc�logger�debug)rIrhris   r*�savezAccountMemoryStorage.saveus7���:�:����&��L�L�2�G�J�J�?�$+��
�
�g�j�j�!r)�
account_idc�f�	|j|S#t$rtj|��wxYwrW)rc�KeyErrorr�AccountNotFound�rIrns  r*�loadzAccountMemoryStorage.loadzs6��	5��=�=��,�,���	5��(�(��4�4�	5�s��0rW)rrrr r	rr'rrKrrgr
rmrsr(r)r*r`r`lsg��$�Q��$�s�G�|�2D�)E�Q�QU�Q�,�$�w�-�,�,�G�,�X�,�$�,�
5�s�5�w�5r)r`c���eZdZdZdej
ddfd�Zdedefd�Zdededefd	�Z	e
d
edefd��Ze
d
edefd��Ze
d
edefd
��Z
dedeefd�Zdeefd�Zdedededdfd�Zdededdfd�Zdededefd�Zdedefd�Zdededdfd�Zdeddfd�Zdeddfd�Zdeddfd�Zdededdfd�Zdeddfd�Zdedeegefdefd�Zdedefd�Zded eddfd!�Z ded eddfd"�Z!ded eddfd#�Z"y)$�AccountFileStoragezjAccounts file storage.

    :ivar certbot.configuration.NamespaceConfig config: Client configuration

    �configr/Nc�|�||_tj|jd|jj�y�Ni�)rvr�make_or_verify_dir�accounts_dir�strict_permissions)rIrvs  r*rKzAccountFileStorage.__init__�s+��������� 3� 3�U�D�K�K�<Z�<Z�[r)rnc�N�|j||jj�SrW)�!_account_dir_path_for_server_pathrv�server_pathrrs  r*�_account_dir_pathz$AccountFileStorage._account_dir_path�s���5�5�j�$�+�+�BY�BY�Z�Zr)r~c�x�|jj|�}tjj	||�SrW)rv�accounts_dir_for_server_pathr�path�join)rIrnr~rzs    r*r}z4AccountFileStorage._account_dir_path_for_server_path�s+���{�{�?�?��L���w�w�|�|�L�*�5�5r)�account_dir_pathc�B�tjj|d�S)Nz	regr.json�rr�r���clsr�s  r*�
_regr_pathzAccountFileStorage._regr_path�����w�w�|�|�,�k�:�:r)c�B�tjj|d�S)Nzprivate_key.jsonr�r�s  r*�	_key_pathzAccountFileStorage._key_path�s���w�w�|�|�,�.@�A�Ar)c�B�tjj|d�S)Nz	meta.jsonr�r�s  r*�_metadata_pathz!AccountFileStorage._metadata_path�r�r)c��|jj|�}	tj|�}g}|D]$}	|j|j
||���&|sM|tjvr;tj|}|j|�}|r	|j||�|}|S#t$rgcYSwxYw#tj$rtjdd��Y��wxYw#t$rgcYSwxYw)NzAccount loading problemT)�exc_info)rvr�r�listdir�OSError�append�_load_for_server_pathr�AccountStorageErrorrkrlr�LE_REUSE_SERVERS�_find_all_for_server_path�_symlink_to_accounts_dir)rIr~rz�
candidatesrcrn�prev_server_path�
prev_accountss        r*r�z,AccountFileStorage._find_all_for_server_path�s
���{�{�?�?��L��	����L�1�J���$�	G�J�
G����� :� :�:�{� S�T�	G��K�9�+E�+E�E�(�9�9�+�F�� �:�:�;K�L�M����1�1�2B�K�P�%�H����+�	��I�	���-�-�
G����6���F�
G�����I��s4�B.�!B?�C/�.B<�;B<�?*C,�+C,�/C=�<C=c�L�|j|jj�SrW)r�rvr~rPs r*rgzAccountFileStorage.find_all�s���-�-�d�k�k�.E�.E�F�Fr)r�c�x�|j||�}|j||�}tj||�yrW)r}r�symlink)rIr�r~rn�prev_account_dir�new_account_dirs      r*�_symlink_to_account_dirz*AccountFileStorage._symlink_to_account_dir�s7���A�A�*�N^�_���@�@��[�Y��
�
�
�#�_�5r)c�0�|jj|�}tjj	|�rtj
|�ntj|�|jj|�}tj||�yrW)rvr�rr��islink�unlink�rmdirr�)rIr�r~rzr�s     r*r�z+AccountFileStorage._symlink_to_accounts_dir�sc���{�{�?�?��L��
�7�7�>�>�,�'��I�I�l�#��H�H�\�"��;�;�C�C�DT�U��
�
�
�#�\�2r)c�F�|j||�}tjj|�s�|tj
vr~tj
|}|j
||�}|jj|�}tj|�r|j|||�|S|j||�|Stjd|�d���	t|j|��5}t j"j%|j'��}ddd�t|j)|��5}	t*j,j%|	j'��}
ddd�t|j/|��5}t0j2j%|j'��}ddd�t1
�S#1swY��xYw#1swY�rxYw#1swY�.xYw#t4$r}
tj6|
��d}
~
wwxYw)N�Account at � does not exist)r}rr��isdirrr�r�rvr�r�r�r�rrq�openr�rr[�
json_loads�readr�r%r\r�rr+�IOErrorr�)rIrnr~r�r��prev_loaded_accountrz�	regr_filer,�key_filer-�
metadata_filer.�errors              r*r�z(AccountFileStorage._load_for_server_path�s����A�A�*�k�Z���w�w�}�}�-�.��i�8�8�8�#,�#=�#=�k�#J� �&*�&@�&@��M]�&^�#�#�{�{�G�G��T���:�:�l�+��0�0�1A�;�PZ�[�+�*��1�1�2B�K�P�*�*��(�(�;�7G�6H��)X�Y�Y�	4��d�o�o�&6�7�8�
R�I��4�4�?�?�	���@P�Q��
R��d�n�n�%5�6�7�
;�8��h�h�)�)�(�-�-�/�:��
;��d�)�)�*:�;�<�
E�
��|�|�.�.�}�/A�/A�/C�D��
E�
�t�S�$�'�'�
R�
R��
;�
;��
E�
E���	4��,�,�U�3�3��	4�s`�G=�6.G�$"G=�.G%�4"G=�.G1�G=�G"�G=�%G.�*G=�1G:�6G=�=	H �H�H c�N�|j||jj�SrW)r�rvr~rrs  r*rszAccountFileStorage.load�s���)�)�*�d�k�k�6M�6M�N�Nr)rhric���	|j|�}|j||�|j||�|j||�y#t$r}tj|��d}~wwxYw)z�Create a new account.

        :param Account account: account to create
        :param ClientV2 client: ACME client associated to the account

        N)�_prepare�_create�_update_meta�_update_regrr�rr�)rIrhri�dir_pathr�s     r*rmzAccountFileStorage.save�sd��	4��}�}�W�-�H��L�L��(�+����g�x�0����g�x�0���	4��,�,�U�3�3��	4�s�AA
�
	A-�A(�(A-c��	|j|�}|j||�y#t$r}tj|��d}~wwxYw)z^Update the registration resource.

        :param Account account: account to update

        N)r�r�r�rr��rIrhr�r�s    r*�update_regrzAccountFileStorage.update_regr��F��	4��}�}�W�-�H����g�x�0���	4��,�,�U�3�3��	4���#&�	A	�A�A	c��	|j|�}|j||�y#t$r}tj|��d}~wwxYw)zVUpdate the meta resource.

        :param Account account: account to update

        N)r�r�r�rr�r�s    r*�update_metazAccountFileStorage.update_metar�r�c��|j|�}tjj|�st	j
d|�d���|j
||jj�tj|jj�s&|j|jj�yy)znDelete registration info from disk

        :param account_id: id of account which should be deleted

        r�r�N)rrr�r�rrq�#_delete_account_dir_for_server_pathrvr~r�rz�$_delete_accounts_dir_for_server_path)rIrnr�s   r*�deletezAccountFileStorage.deletes��� �1�1�*�=���w�w�}�}�-�.��(�(�;�7G�6H��)X�Y�Y��0�0��T�[�[�=T�=T�U��z�z�$�+�+�2�2�3��5�5�d�k�k�6M�6M�N�4r)c��tj|j|�}|j||�}t	j
|�yrW)�	functools�partialr}�!_delete_links_and_find_target_dir�shutil�rmtree)rIrnr~�	link_func�nonsymlinked_dirs     r*r�z6AccountFileStorage._delete_account_dir_for_server_path!s:���%�%�d�&L�&L�j�Y�	��A�A�+�y�Y���
�
�&�'r)c�~�|jj}|j||�}tj|�yrW)rvr�r�rr�)rIr~r�r�s    r*r�z7AccountFileStorage._delete_accounts_dir_for_server_path&s1���K�K�<�<�	��A�A�+�y�Y��
���!�"r)r�c���||�}i}tjj�D]
\}}|||<�d}|rSd}||vrJ||}||�}	tjj|	�rt
j|	�|k(rd}|}|	}|r�Stjj|�rLt
j|�}
tj|�|
}tjj|�r�L|S)a/Delete symlinks and return the nonsymlinked directory path.

        :param str server_path: file path based on server
        :param callable link_func: callable that returns possible links
            given a server_path

        :returns: the final, non-symlinked target
        :rtype: str

        TF)	rr��itemsrr�r�r�readlinkr�)rIr~r�r��reused_servers�k�v�possible_next_link�next_server_path�
next_dir_path�targets           r*r�z4AccountFileStorage._delete_links_and_find_target_dir+s����[�)�����.�.�4�4�6�	"�D�A�q� !�N�1��	"�"�� �!&���n�,�#1�+�#>� � )�*:� ;�
��7�7�>�>�-�0�Z�5H�5H��5W�[c�5c�)-�&�"2�K�,�H�!��g�g�n�n�X�&��(�(��2�F��I�I�h���H��g�g�n�n�X�&�
�r)c��|j|j�}tj|d|jj
�|Srx)rrHrryrvr{)rIrhr�s   r*r�zAccountFileStorage._prepareSs:���1�1�'�*�*�=����� 0�%����9W�9W�X��r)r�c���tj|j|�dd��5}|j|jj��ddd�y#1swYyxYw)N�w�)�chmod)r�	safe_openr��writer-�
json_dumps)rIrhr�r�s    r*r�zAccountFileStorage._createXsK��
�^�^�D�N�N�8�4�c��
G�	5�8��N�N�7�;�;�1�1�3�4�	5�	5�	5�s�*A�A$c��t|j|�d�5}tji|jj
��}|j
|j��ddd�y#1swYyxYw)Nr�)�body�uri)r�r�rr[r,r�r�r�)rIrhr�r�r,s     r*r�zAccountFileStorage._update_regr\sa��
�$�/�/�(�+�S�
1�	/�Y��0�0���L�L�$�$�&�D�
�O�O�D�O�O�-�.�		/�	/�	/�s�AA0�0A9c��t|j|�d�5}|j|jj	��ddd�y#1swYyxYw)Nr�)r�r�r�r.r�)rIrhr�r�s    r*r�zAccountFileStorage._update_metacsI��
�$�%�%�h�/��
5�	;�������� 7� 7� 9�:�	;�	;�	;�s�*A�A)#rrrr r�NamespaceConfigrKr'rr}�classmethodr�r�r�rrr�rgr�r�r�rsr
rmr�r�r�r�r�rr�r�r�r�r�r(r)r*ruru�sc���
\�}�<�<�\��\�[�C�[�C�[�6�C�6�c�6�VY�6��;�#�;�#�;��;��B��B��B��B��;�c�;�c�;��;��S��T�'�]��6G�$�w�-�G�6��6�#�6�,/�6�48�6�3��3�3�3�SW�3�(��(�#�(�'�(�8O�s�O�w�O�
4�G�
4�X�
4�$�
4�
4�7�
4�t�
4�
4�7�
4�t�
4�O��O��O� (�c�(�PS�(�X\�(�
#��#��#�
&�S�&�5=�s�e�S�j�5I�&�NQ�&�P �� �C� �
5�w�5�#�5�$�5�/�G�/�s�/�t�/�;�G�;�s�;�t�;r)ru),r r#r�r=�loggingr�r;�typingrrrrrrr	�cryptography.hazmat.primitivesr
�josepyr%rNr8�acmerr!r�acme.clientr
�certbotrrrr�certbot._internalr�certbot.compatrr�	getLoggerrrkr�AccountStorager`rur(r)r*�<module>r�s���'�����
�
��������8����&�� �!����'�%��	��	�	�8�	$��F)�F)�R5�:�4�4�5�*d;��2�2�d;r)

Zerion Mini Shell 1.0