Spade
Mini Shell
| Directory:~$ /proc/self/root/usr/lib/python2.7/site-packages/certbot/_internal/ |
| [Home] [System Details] [Kill Me] |
�
���_c@s�dZddlZddlZddlZddlZddlZddlZddlm Z ddl
mZddl
mZddl
m
Z
ddl
mZddl
mZdd lmZdd
lmZddlmZeje�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Z
d�Z!d�Z"d�Z#e$d�Z%e$dd�Z'd�Z(d�Z)d�Z*d�Z+dS(s
Tools for managing
certificates.i����N(tList(tcrypto_util(terrors(t
interfaces(tocsp(tutil(tstorage(toscCs4x-tj|�D]}tj||dt�qWdS(sjUpdate
the certificate file family symlinks to use archive_dir.
Use the information in the config file to make symlinks point to
the correct archive directory.
.. note:: This assumes that the installation is using a Reverter
object.
:param config: Configuration.
:type config: :class:`certbot._internal.configuration.NamespaceConfig`
tupdate_symlinksN(Rtrenewal_conf_filest
RenewableCerttTrue(tconfigtrenewal_file((sB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pytupdate_live_symlinksscCs�tjjtj�}t|d�d}|j}|s�|jdj|�dddt �\}}|t
jksw|r�tj
d��q�nt||�}|s�tjdj|���ntj|||�|jd j||�d
t�dS(s�Rename the specified lineage to the new name.
:param config: Configuration.
:type config: :class:`certbot._internal.configuration.NamespaceConfig`
trenameis&Enter the new name for certificate
{0}tflags--updated-cert-nametforce_interactivesUser ended
interaction.s,No existing certificate with name {0} found.s Successfully
renamed {0} to {1}.tpauseN(tzopet componentt
getUtilityRtIDisplayt
get_certnamestnew_certnametinputtformatRtdisplay_utiltOKRtErrortlineage_for_certnametConfigurationErrorRtrename_renewal_configtnotificationtFalse(RtdisptcertnameRtcodetlineage((sB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pytrename_lineage)s
cCs�g}g}x�tj|�D]�}y0tj||�}tj|�|j|�Wqtk
r�}tjd||�tj dt
j��|j|�qXqWt|||�dS(s�Display information about
certs configured with Certbot
:param config: Configuration.
:type config: :class:`certbot._internal.configuration.NamespaceConfig`
sIRenewal configuration file %s produced an unexpected error: %s.
Skipping.sTraceback was:
%sN(
RR R
Rtverify_renewable_certtappendt Exceptiontloggertwarningtdebugt tracebackt
format_exct_describe_certs(Rtparsed_certstparse_failuresR
trenewal_candidatete((sB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pytcertificatesEs
cCs�t|ddt�}tjjtj�}dg}x|D]}|jd|�q:W|jd�|jdj |�dt�s�t
jd�d Sx4|D],}tj
||�tjd
j|��q�Wd S(s;Delete Certbot files associated with a certificate
lineage.tdeletetallow_multiples8The following certificate(s) are selected
for deletion:
s * s:
Are you sure you want to delete the above certificate(s)?s
tdefaults$Deletion of certificate(s) canceled.Ns.Deleted all files
relating to certificate
{0}.(RRRRRRRR)tyesnotjoinR+tinfoRtdelete_filesRtnotifyR(Rt certnamesR#tmsgR$((sB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pyR6\s
cCs�|j}tj|dd�ytj||�}Wntjk
rIdSXytj||�SWnAtjt fk
r�t
jd|�t
jdtj
��dSXdS(s)Find a lineage object with name
certname.tmodei�sRenewal conf file %s is broken.sTraceback was:
%sN(trenewal_configs_dirRtmake_or_verify_dirRtrenewal_file_for_certnameRtCertStorageErrortNoneR
tIOErrorR+R-R.R/(t
cli_configR$tconfigs_dirR
((sB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pyRps cCs#t||�}|r|j�SdS(s0Find
the domains in the cert with name
certname.N(RtnamesRE(RR$R&((sB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pytdomains_for_certname�scs�fd�}t||d�S(s�Find
existing certs that match the given domain names.
This function searches for certificates whose domains are equal to
the `domains` parameter and certificates whose domains are a subset
of the domains in the `domains` parameter. If multiple certificates
are found whose names are a subset of `domains`, the one whose names
are the largest subset of `domains` is returned.
If multiple certificates' domains are an exact match or equally
sized subsets, which matching certificates are returned is
undefined.
:param config: Configuration.
:type config: :class:`certbot._internal.configuration.NamespaceConfig`
:param domains: List of domain names
:type domains: `list` of `str`
:returns: lineages representing the identically matching cert and the
largest subset if they exist
:rtype: `tuple` of `storage.RenewableCert` or `None`
cs�|\}}t|j��}|t��kr9|}nT|jt���r�|dkrc|}q�t|�t|j��kr�|}q�n||fS(ssReturn
cert as identical_names_cert if it matches,
or subset_names_cert if it matches as subset
N(tsetRItissubsetREtlen(tcandidate_lineagetrvtidentical_names_certtsubset_names_certtcandidate_names(tdomains(sB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pytupdate_certs_for_domain_matches�s N(NN(t_search_lineagesRE(RRSRT((RSsB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pytfind_duplicative_certs�scCsc|j}gtj|�D]6}tjdj|�|�rtjj||�^q}|r_|SdS(sJ
In order to match things like:
/etc/letsencrypt/archive/example.com/chain1.pem.
Anonymous functions which call this function are eventually passed
(in a list) to
`match_and_check_overlaps` to help specify the acceptable_matches.
:param `.storage.RenewableCert` candidate_lineage: Lineage whose
archive dir is to
be searched.
:param str filetype: main file name prefix e.g.
"fullchain" or "chain".
:returns: Files in candidate_lineage's archive dir that match
the provided filetype.
:rtype: list of str or None
s
{0}[0-9]*.pemN( tarchive_dirRtlistdirtretmatchRtpathR:RE(RNtfiletypeRWtftpattern((sB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pyt_archive_files�s 6cCsd�d�d�d�gS(s�
Generates the list that's passed to match_and_check_overlaps. Is its
own function to
make unit testing easier.
:returns: list of functions
:rtype: list
cSs|jS(N(tfullchain_path(tx((sB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pyt<lambda>�scSs|jS(N(t cert_path(Ra((sB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pyRb�scSs
t|d�S(Ntcert(R_(Ra((sB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pyRb�scSs
t|d�S(Nt fullchain(R_(Ra((sB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pyRb�s((((sB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pyt_acceptable_matches�scs2t�}t�|�fd�d��}|dS(s�
If config.cert_path is defined, try to find an appropriate value for
config.certname.
:param `configuration.NamespaceConfig` cli_config: parsed command line
arguments
:returns: a lineage name
:rtype: str
:raises `errors.Error`: If the specified cert path can't be
matched to a lineage name.
:raises `errors.OverlappingMatchFound`: If the matched lineage's
archive is shared.
cs�jdS(Ni(Rc(Ra(RG(sB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pyRb�scSs|jS(N(tlineagename(Ra((sB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pyRb�si(Rftmatch_and_check_overlaps(RGtacceptable_matchesRZ((RGsB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pytcert_path_to_lineage�s cst��fd�}t||g|�}|sOtjdj|jd���n!t|�dkrptj��n|S(s
Searches through all lineages for a match, and checks for duplicates.
If a duplicate is found, an error is raised, as performing operations
on lineages
that have their properties incorrectly duplicated elsewhere is probably
a bad idea.
:param `configuration.NamespaceConfig` cli_config: parsed command line
arguments
:param list acceptable_matches: a list of functions that specify
acceptable matches
:param function match_func: specifies what to match
:param function rv_func: specifies what to return
cs�g|D]}||�^q}g}x7|D]/}t|t�rN||7}q,|j|�q,W�|�}||kr�|j�|��n|S(s1Returns
a list of matches using _search_lineages.(t
isinstancetlistR)(RNtreturn_valueRitfunctacceptable_matches_rvtitemRZ(t
match_functrv_func(sB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pytfind_matches�s
s!No
match found for cert-path
{0}!ii(RURRRRcRMtOverlappingMatchFound(RGRiRqRrRstmatched((RqRrsB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pyRh�s"cCs�g}tj�}|jr8|j|jkr8|r8dS|jrdt|j�j|j��rddStj j
tjj��}g}|j
r�|jd�n|j|kr�|jd�n|j|�r�|jd�n|r�ddj|�}n_|j|}|jdkrd}n:|jdkrEd j|jd
�}ndj|j�}dj|j|�} ttj|j�d
�}
|jdj|j|
|jdj|j��| |j|j��dj|�S(sJ Returns a human
readable description of info about a RenewableCert
objecttt TEST_CERTtEXPIREDtREVOKEDs INVALID: s, isVALID: 1 daysVALID:
{0} hour(s)isVALID: {0} dayss {0} ({1})Ras� Certificate Name: {}
Serial Number: {}
Key Type: {}
Domains: {}
Expiry Date: {}
Certificate Path: {}
Private Key Path: {}t
(RtRevocationCheckerR$RgRSRKRLRItpytztUTCtfromutctdatetimetutcnowtis_test_certR)t
target_expirytocsp_revokedR:tdaysRtsecondsRtget_serial_from_certRctprivate_key_typeRetprivkey(RRdtskip_filter_checkstcertinfotcheckertnowtreasonststatustdifftvalid_stringtserial((sB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pythuman_readable_cert_infosB"(
c
Cst|j}|r|g}nUtjjtj�}tj|�}g|D]}tj|�^qF} | syt j
d��n|r�|s�dj|�}
n|}
|j|
| dddt
�\}}|tjkrpt j
d��qpn�|s�dj|�}
n|}
|j|
| dddt
�\}}|tjksQ|tdt| ��krct j
d��n| |g}|S( s9Get certname from flag, interactively, or error
out.
sNo existing certificates found.s+Which certificate(s) would you like
to {0}?tcli_flags--cert-nameRsUser ended interaction.s(Which
certificate would you like to
{0}?i(R$RRRRRRR tlineagename_for_filenameRRRt checklistRRRtmenutrangeRM(
RtverbR7t
custom_promptR$R>R#t filenamestnametchoicestpromptR%tindex((sB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pyR8s2 "*
cCsddjd�|D��S(sFFormat
a results report for a category of single-line renewal outcomess s
css|]}t|�VqdS(N(tstr(t.0R?((sB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pys <genexpr>bs(R:(tmsgs((sB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pyt
_report_lines`scCs:g}x$|D]}|jt||��q
Wdj|�S(s)Format
a results report for a parsed certs
(R)R�R:(RR1R�Rd((sB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pyt_report_human_readablees
cCs�g}|j}|r*|r*|d�np|rw|jsB|jrHdnd}|dj|��|t||��n|r�|d�|t|��ntjjt j
�}|jdj|�dt
dt
�d S(
s/Print information about the certs we know aboutsNo certificates
found.s matching RvsFound the following {0}certs:s3
The following renewal configurations were invalid:s
RtwrapN(R)R$RSRR�R�RRRRRR!R:R"(RR1R2toutR=RZR#((sB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pyR0ms
cGs�|j}tj|dd�|}x�tj|�D]t}ytj||�}WnCtjtfk
r�t j
d|�t j
dtj��q2nX||||�}q2W|S(s�Iterate func over unbroken
lineages, allowing custom return conditions.
Allows flexible customization of return values, including multiple
return values and complex checks.
:param `configuration.NamespaceConfig` cli_config: parsed command line
arguments
:param function func: function used while searching over lineages
:param initial_rv: initial return value of the function (any type)
:returns: Whatever was specified by `func` if a match is found.
R@i�s)Renewal conf file %s is broken. Skipping.sTraceback was:
%s(
RARRBRR R
RRDRFR+R-R.R/(RGRnt
initial_rvtargsRHROR
RN((sB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pyRU�s (,t__doc__RtloggingRYR.R|tzope.componentRtacme.magic_typingRtcertbotRRRRRtcertbot._internalRtcertbot.compatRtcertbot.displayRt getLoggert__name__R+RR'R5R6RRJRVR_RfRjRhR"R�RERR�R�R0RU(((sB/usr/lib/python2.7/site-packages/certbot/_internal/cert_manager.pyt<module>sB - !1(