M/e JdZddlZddlZddlZddlZddlZddlZddlmZddlm Z ddlm Z ddlm Z ddlm Z ddlm Z dd lmZdd lmZdd lmZddlZdd lmZdd lmZddlmZddlmZddlZddlZddlZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z"ddl#m$Z$ddl#m%Z%ddl&m'Z(ddl)m*Z*ddl)m+Z+ddl,m-Z.ddl/m0Z0ejbe2Z3dZ4dZ5e0ejlZ7dZ8d ejrd!e e:fd"Z;d ejrd#e:d!e:fd$Ze:d!eFfd?ZHd ejrd!e e:effd@ZIdAe:d!e:fdBZJd ejrd6e:d!e:fdCZKd.e:dDe:d!e:fdEZLdFej|d4ejrd6e:d!e:fdGZMd4ejrd6e:d!e:fdHZNd ejrd#e:d!dfdIZOGdJdKe jZPy)NzRenewable certificates storage.N)Any)cast)Dict)Iterable)List)Mapping)Optional)Tuple)Union)default_backend)EllipticCurvePrivateKey) RSAPrivateKey)load_pem_private_key configuration) crypto_util)errors) interfaces)ocsp)util) constants) error_handler)disco) filesystem)os)common)parse_loose_version)certprivkeychain fullchainREADMEiconfigreturnctjtjj|jd}|j |S)zBuild a list of all renewal configuration files. :param configuration.NamespaceConfig config: Configuration object :returns: list of renewal configuration files :rtype: `list` of `str` z*.conf)globrpathjoinrenewal_configs_dirsort)r#results ;/usr/lib/python3/dist-packages/certbot/_internal/storage.pyrenewal_conf_filesr-4s5YYrww||F$>$>I JF KKM Mcertnamectjj|j|d}tjj |st j d|d|d|S)z;Return /path/to/certname.conf in the renewal conf directory.confzNo certificate found with name z (expected z).)rr'r(r)existsrCertStorageError)r#r/r's r,renewal_file_for_certnamer4Bs_ 77<<22xj4F GD 77>>$ %%-hZ{4& KM M Kr. cert_namecPt||}tj|dddS)z If `--cert-name` was specified, but you need a value for `--cert-path`. :param configuration.NamespaceConfig config: parsed command line arguments :param str cert_name: cert name. utf-8encodingdefault_encodingr!)r4 configobj ConfigObj)r#r5cert_name_implied_confs r,cert_path_for_cert_namer>Ks67vyI   7 LLW YYr.ctjtjdd}|j |||Stjdd|S)z?Merge supplied config, if provided, on top of builtin defaults.r7r8)r;r<rRENEWER_DEFAULTSmerge)r# defaults_copys r,config_with_defaultsrCWs^''""WwPM&"45 ;D:M:M7;45 r. base_timeinterval textparserc|jjr|dz }|jxstj}|j |||dS)aParse the time specified time interval, and add it to the base_time The interval can be in the English-language format understood by parsedatetime, e.g., '10 days', '3 weeks', '6 months', '9 hours', or a sequence of such intervals like '6 months 1 week' or '3 days 12 hours'. If an integer is found with no associated unit, it is interpreted by default as a number of days. :param datetime.datetime base_time: The time to be added with the interval. :param str interval: The time interval to parse. :returns: The base_time plus the interpretation of the time interval. :rtype: :class:`datetime.datetime`z days)tzinfor)stripisdigitrHpytzUTCparseDT)rDrErFrHs r,add_time_intervalrNasT"~~!G   )F   h &  A! DDr. o_filename n_filename archive_dirtarget relevant_datactj|dd}tj|d<||d<tD] }||||< d|vri|d<ddg|j d<|dj ||dD] }||vs|d|=d|vrtjd}d |zg|_ tjd |t|d 5 d d d tjj|rHt!j"tj$|j&} t)j*|| t|d 5} |j-| d d d |S#1swYxYw#1swY|SxYw)aWrites a renewal config file with the specified name and values. :param str o_filename: Absolute path to the previous version of config file :param str n_filename: Absolute path to the new destination of config file :param str archive_dir: Absolute path to the archive directory :param dict target: Maps ALL_FOUR to their symlink paths :param dict relevant_data: Renewal configuration options to save :returns: Configuration object for the new config file :rtype: configobj.ConfigObj r7r8versionrQ renewalparamsz#Options used in the renewal processrenew_before_expiryzrenew_before_expiry = zWriting new config %s.aNwb)outfile)r;r<certbot __version__ALL_FOURcommentsupdaterr@initial_commentloggerdebugopenrr'r2statS_IMODElstatst_moderchmodwrite) rOrPrQrRrSr#kindkdefault_intervalcurrent_permissionsfs r,write_renewal_configrp{s gPW XF++F9'F=$d|t $f$"$,.-B,C( ?""=1 O $+ M !'*+F*$556KL":=M"M!N LL):6 j#     ww~~j!"ll288J+?+G+GH%89 j$  1 Q  M   Ms E%E1%E.1E; prev_namenew_name cli_configct||}t||}tjj|rt j d t j||y#t$rt j dwxYw)zRenames cli_config.certname's config to cli_config.new_certname. :param .NamespaceConfig cli_config: parsed command line arguments z+The new certificate name is already in use.z=Please specify a valid filename for the new certificate name.N) renewal_filename_for_lineagenamerr'r2rConfigurationErrorrreplaceOSError)rqrrrs prev_filename new_filenames r,rename_renewal_configr{s5ZKM3JIL ww~~l#'')!" "-=,7 -''),- --s A%%B lineagenamect||}|dz}tjj|rtj|t |}t |||||tj||tj|ddS)aModifies lineagename's config to contain the specified values. :param str lineagename: Name of the lineage being modified :param str archive_dir: Absolute path to the archive directory :param dict target: Maps ALL_FOUR to their symlink paths :param .NamespaceConfig cli_config: parsed command line arguments :returns: Configuration object for the updated config file :rtype: configobj.ConfigObj z.newr7r8) rurr'r2unlinkrelevant_valuesrprrwr;r<)r|rQrRrsconfig_filename temp_filenamevaluess r,update_configurationrsz7z;OO#f,M ww~~m$ - Z (F-ffU}o6   SZ [[r.linkc tj|}t jj|s=t jjt jj||}t jj|S#t$r%tjdj |wxYw)zGet an absolute path to the target of link. :param str link: Path to a symbolic link :returns: Absolute path to the target of link :rtype: str :raises .CertStorageError: If link does not exists. zExpected {0} to be a symlink) rreadlinkrxrr3formatrr'isabsr(dirnameabspath)rrRs r,get_link_targetrs9$$T* 77== bggood3V< 77??6 "" 9%% * 1 1$ 79 99s B.C readme_path is_base_dircd}|rd}t|d5}tjd||jdj |dddy#1swYyxYw)NrWz [cert name]/wzWriting README to %s.aThis directory contains your keys and certificates. `{prefix}privkey.pem` : the private key for your certificate. `{prefix}fullchain.pem`: the certificate file used in most server software. `{prefix}chain.pem` : used for OCSP stapling in Nginx >=1.3.7. `{prefix}cert.pem` : will break many server configurations, and should not be used without reading further documentation (see link below). WARNING: DO NOT MOVE OR RENAME THESE FILES! Certbot expects these files to remain in this location in order to function properly! We recommend not moving these files. For more information, see the Certbot User Guide at https://certbot.eff.org/docs/using.html#where-are-my-certificates. )prefix)rdrbrcrjr)rrrros r,_write_live_readme_torsc F k3 M1 ,k:  67=fFf6K MMMMs 8AA namespacesoptioncXddlm}|jvxstfd|DS)z Is this option one that could be restored for future renewal purposes? :param namespaces: plugin namespaces for configuration options :type namespaces: `list` of `str` :param str option: the name of the option :rtype: bool r)renewalc3@K|]}j|ywN) startswith).0 namespacers r, z_relevant..sI!!),I)certbot._internalr CONFIG_ITEMSany)rrrs ` r, _relevantr s0* g** * J IjI IKr.c\|j}tjj}|Dcgc]}t j |}}|j Dcic]%\}}t||r|j|r||'}}}|d|d<|d|d<|Scc}wcc}}w)zReturn a new dict containing only items relevant for renewal. :param .NamespaceConfig config: parsed command line :returns: A new dictionary containing items that can be used in renewal. :rtype dict: serverkey_type) to_dict plugins_discoPluginsRegistryfind_allplugins_commondest_namespaceitemsr set_by_user)r# all_valuespluginspluginrrvaluervs r,rrs!J++446GFMNF.//7NJN(--/  FE Z (V-?-?-G   B h'BxL +BzN I!O s B#$*B(rc|jdstjdtjj |dt d S):Returns the lineagename for a configuration filename. r1z*renewal config file name must end in .confN)endswithrr3rr'basenamelen)rs r,lineagename_for_filenamer;sJ  # #G ,%% 8: : 77  ONc'l]; <d:e ddfd;Z;y)? RenewableCertaRenewable certificate. Represents a lineage of certificates that is under the management of Certbot, indicated by the existence of an associated renewal configuration file. Note that the notion of "current version" for a lineage is maintained on disk in the structure of symbolic links, and is not explicitly stored in any instance variable in this object. The RenewableCert object is able to determine information about the current (or other) version by accessing data on disk, but does not inherently know any of this information except by examining the symbolic links as needed. The instance variables mentioned below point to symlinks that reflect the notion of "current version" of each managed object, and it is these paths that should be used when configuring servers to use the certificate managed in a lineage. These paths are normally within the "live" directory, and their symlink targets -- the actual cert files -- are normally found within the "archive" directory. :ivar str cert: The path to the symlink representing the current version of the certificate managed by this lineage. :ivar str privkey: The path to the symlink representing the current version of the private key managed by this lineage. :ivar str chain: The path to the symlink representing the current version of the chain managed by this lineage. :ivar str fullchain: The path to the symlink representing the current version of the fullchain (combined chain and cert) managed by this lineage. :ivar configobj.ConfigObj configuration: The renewal configuration options associated with this lineage, obtained from parsing the renewal configuration file and/or systemwide defaults. rrsupdate_symlinksr$Nc|_t|_ tj|dd_tj _ tfdtDs.tjdjj jjd}|8t|t kDr&t"j%d||t&j(jd _jd _jd _jd _t2j4j7j*_j;|rj=j?y#tj $r%tjdj|wxYw) aInstantiate a RenewableCert object from an existing lineage. :param str config_filename: the path to the renewal config file that defines this lineage. :param .NamespaceConfig: parsed command line arguments :raises .CertStorageError: if the configuration file's name didn't end in ".conf", or the file is missing or broken. r7r8rc3:K|]}|jvywrrrxselfs r,rz)RenewableCert.__init__..s=q1***=sz>r.c@|jdjddS)z8Returns the ACME server associated with this certificaterVrN)rrrs r,rzRenewableCert.server6s"!!/266xFFr.cZ|jrtj|jSy)z:Returns true if this is a test cert from a staging server.F)rr is_stagingrs r, is_test_certzRenewableCert.is_test_cert;s! ;;??4;;/ /r.cdd|jdvxr|jdjdS)zGReturns whether this certificate is configured to reuse its private key reuse_keyrVras_boolrs r,rzRenewableCert.reuse_keyBs<d00AAH!!/2::;G Hr.cVtD]}t||}tjj |s$t j dj|t|}tjj|r}t j dj||y)z.Raises an exception if a symlink doesn't existzexpected {0} to be a symlinkz(target {0} of symlink {1} does not existN) r^getattrrr'islinkrr3rrr2)rrkrrRs r,rzRenewableCert._check_symlinksHs PD4&D77>>$'--299$?AA$T*F77>>&)--/::@&:NPP Pr.c6tD]}t||}t|}tjj |j |tjj|}tj|tj||y)z#Updates symlinks to use archive_dirN) r^rrrr'r(rrr~symlink)rrkr previous_linknew_links r,rzRenewableCert._update_symlinksTss 'D4&D+D1Mww||D$=$=d$C  /1H IIdO JJx & 'r.cH|j|j|j|jfD]9}tj j |r#tjd|y|j|j|j|jfD]9}tj j|r#tjd|ytD]D}t||}t|}tj jtj j||jsAtjd|tj j||jytj j!|stjd||yt#j$dj'|}|j)tj j+|r/tjd|yy) zAre the files associated with this lineage self-consistent? :returns: Whether the files stored in connection with this lineage appear to be correct and consistent with one another. :rtype: bool z3Element %s is not referenced with an absolute path.Fz"Element %s is not a symbolic link.a-Element's link does not point within the cert lineage's directory within the official archive directory. Link: %s, target directory: %s, archive directory: %s. If you've specified the archive directory in the renewal configuration file, you may need to update links by running certbot update_symlinks.z.Link %s points to file %s that does not exist.^{0}([0-9]+)\.pem$z1%s does not follow the archive naming convention.T)rrr r!rr'rrbrcrr^rrsamefilerrQr2recompilermatchr)rrrkrrRpatterns r, _consistentzRenewableCert._consistent_s))T\\4::t~~F A77==# ./02  ))T\\4::t~~F A77>>!$ A1E  D4&D$T*F77##BGGOOF$;T=M=MN 8"277??6#:D>&) M!6+jj!6!=!=d!CDG==!1!1&!9: +,24= Zr.cy)zpAttempt to fix defects or inconsistencies in this lineage. .. todo:: Currently unimplemented. Nrs r,_fixzRenewableCert._fixsr.cg}tD]m}tjjt ||}dj |}|j |tjj||fo|S)zReturns the kind and path of all symlinks used in recovery. :returns: list of (kind, symlink) tuples :rtype: list zprevious_{0}.pem)r^rr'rrrappendr()rprevious_symlinksrklink_dir link_bases r,_previous_symlinksz RenewableCert._previous_symlinkssn PDwwwtT':;H*11$7I  $ $dBGGLL9,M%N O P ! r.c|j}td|Drs|D]n\}}t||}tjj |rtj |tjtj||p|D]:\}}tjj|s&tj |<y)zFixes symlinks in the event of an incomplete version update. If there is no problem with the current symlinks, this function has no effect. c3`K|]&}tjj|d(yw)rN)rr'r2)rrs r,rz.RenewableCert._fix_symlinks..s!E4rww~~d1g&Es,.N) rrrrr'lexistsr~rrrr2)rrrkr  current_link_rs r,rzRenewableCert._fix_symlinkss!335 E3DE E'8 M#m&tT2 77??<0IIl+ :..}=|L  M ) GAtww~~d# $ r.rkc|tvrtjdt||}tj j |stjd||yt|S)a(Returns full path to which the specified item currently points. :param str kind: the lineage member item ("cert", "privkey", "chain", or "fullchain") :returns: The path to the current version of the specified member. :rtype: str or None unknown kind of itemz*Expected symlink %s for %s does not exist.N) r^rr3rrr'r2rbrcr)rrkrs r,rzRenewableCert.current_targets\ x ))*@A AtT"ww~~d# LLEt %t$$r.c|tvrtjdtjdj |}|j |}|tjj|stjd||d}|jtjj|}|rt|jdStjd|y)aReturns numerical version of the specified item. For example, if kind is "chain" and the current chain link points to a file named "chain7.pem", returns the integer 7. :param str kind: the lineage member item ("cert", "privkey", "chain", or "fullchain") :returns: the current version of the specified member. :rtype: int r"r Nz3Current-version target for %s does not exist at %s.rWrzNo matches for target %s.)r^rr3rrrrrr'r2rbrcrrintgroups)rrkrrRmatchess r,current_versionzRenewableCert.current_versions x ))*@A A**299$?@$$T* >!7 LL126 @F-- 0 0 89 w~~'*+ + 0$7r.rUc2|tvrtjd|j|}|stjd|dt j j|}t j j|dj||S)aThe filename that corresponds to the specified version and kind. .. warning:: The specified version may not exist in this lineage. There is no guarantee that the file path returned by this method actually exists. :param str kind: the lineage member item ("cert", "privkey", "chain", or "fullchain") :param int version: the desired version :returns: The path to the specified version of the specified member. :rtype: str r"Target  does not exist! {0}{1}.pem) r^rr3rrrr'rr(r)rrkrUrwheres r,rUzRenewableCert.versions~ x ))*@A A""4(,,.>?@ @%ww||E<#6#6tW#EFFr.c |tvrtjd|j|}|stjd|dt j j|}t j|}tjdj|}|Dcgc]}|j|}}t|Dcgc]!}|st|jd#c}Scc}wcc}w)aWhich alternative versions of the specified kind of item exist? The archive directory where the current version is stored is consulted to obtain the list of alternatives. :param str kind: the lineage member item ( ``cert``, ``privkey``, ``chain``, or ``fullchain``) :returns: all of the version numbers that currently exist :rtype: `list` of `int` r"r)r*r r)r^rr3rrrr'rlistdirrrrrsortedr$r%) rrkrr,filesrror&ms r,available_versionsz RenewableCert.available_versionss x ))*@A A""4(,,.>?@ @% 5!**299$?@-237==#337@aas188:a=)@AA4@s&C6 C;C;c6t|j|S)aNewest available version of the specified kind of item? :param str kind: the lineage member item (``cert``, ``privkey``, ``chain``, or ``fullchain``) :returns: the newest available version of this member :rtype: int )maxr2)rrks r,newest_available_versionz&RenewableCert.newest_available_version5s4**4011r.ctDcgc]}|j|c}tfddDScc}w)zNewest version for which all items are available? :returns: the newest available version for which all members (``cert, ``privkey``, ``chain``, and ``fullchain``) exist :rtype: int c3TK|]tfdddDs yw)c3&K|]}|v ywrr)rvns r,rz@RenewableCert.latest_common_version...Ns0NAa0NsrN)r)rr:versionss @r,rz6RenewableCert.latest_common_version..Ns$OS0N!"0N-N1Os((r)r^r2r4)rrr;s @r,latest_common_versionz#RenewableCert.latest_common_versionAs<9AA1D++A.AOhqkOOOBs<c:tfdtDdzS)zSmallest version newer than all full or partial versions? :returns: the smallest version number that is larger than any version of any item currently stored in this lineage :rtype: int c3@K|]}j|ywr)r5rs r,rz2RenewableCert.next_free_version..\sF4003Frr)r4r^rs`r,next_free_versionzRenewableCert.next_free_versionPsFXFFJJr.c|jr5tjd|j|j yy)zMake sure we've deployed the latest version. :returns: False if a change was needed, True otherwise :rtype: bool May need to recover from rare interrupted / crashed states.zMFound a new certificate /archive/ that was not linked to in /live/; fixing...FT)has_pending_deploymentrbwarningupdate_all_links_tor<rs r,ensure_deployedzRenewableCert.ensure_deployed^s>  & & ( NN< =  $ $T%?%?%A Br.cg}tD]>}|j|}|tj|d|j |@t |}||j kS)aIs there a later version of all of the managed items? :returns: ``True`` if there is a complete version of this lineage with a larger version number than the current version, and ``False`` otherwise :rtype: bool z. is required but missing for this certificate.)r^r'rrrminr<)r all_versionsitemrUsmallest_currents r,rAz$RenewableCert.has_pending_deploymentmss#%  )D**40GlldV+Y#Z[[    (  )|,$"<"<">>>r.cp|tvrtjdt||}dj ||}t j jtj|}t j|t jt j j|||y)a7Make the specified item point at the specified version. (Note that this method doesn't verify that the specified version exists.) :param str kind: the lineage member item ("cert", "privkey", "chain", or "fullchain") :param int version: the desired version r"r+N) r^rr3rrrr'rrrr~rr()rrkrUrfilenametarget_directorys r,_update_link_tozRenewableCert._update_link_tos x ))*@A AtT"&&tW577??:+>+>t+DE $ 277<< 0(;TBr.ctj|j5|j}|D]G\}}|j |}|st j d|dtj||ItD]}|j|||D]\}}tj| dddy#1swYyxYw)zwChange all member objects to point to the specified version. :param int version: the desired version r)r*N) r ErrorHandlerrrrrrrrr^rMr~)rrUprevious_linksrkrrRr s r,rCz!RenewableCert.update_all_links_tos  ' '(:(: ; !446N, ) d,,T2 ,,6F'GHH 64(  ) ! 4$$T73 4* 4 $  s BCC c|jd}|tjdt|d5}t j |j cdddS#1swYyxYw)zWhat are the subject names of this certificate? :returns: the subject names :rtype: `list` of `str` :raises .CertStorageError: if could not find cert file. rNz#could not find the certificate filerb)rrr3rdrget_names_from_certread)rrRros r,nameszRenewableCert.namess`$$V, >))*OP P &$  =1221668< = = =s #A""A+c(|jd|}|jd|} tjj||S#t$r>}t j d|t jt|Yd}~yd}~wwxYw)a{Is the specified cert version revoked according to OCSP? Also returns True if the cert version is declared as revoked according to OCSP. If OCSP status could not be determined, False is returned. :param int version: the desired version number :returns: True if the certificate is revoked, otherwise, False :rtype: bool rr z4An error occurred determining the OCSP status of %s.NF) rUrRevocationCheckerocsp_revoked_by_paths ExceptionrbrBrcstr)rrUrres r, ocsp_revokedzRenewableCert.ocsp_revokedsLL1 \\'73  ))+AA)BLN N  NNF  LLQ   s#A B4B  Bcdd|jdvxs|jdjdS)zIs automatic renewal enabled for this cert? If autorenew is not specified, defaults to True. :returns: True if automatic renewal is enabled :rtype: bool autorenewrVrrs r,autorenewal_is_enabledz$RenewableCert.autorenewal_is_enableds<4#5#5o#FFI""?3;;KH Jr.c|jr|j|jrtj dyt j d}|jjd|}tj|jd|j}tjjtj}|t!||kr'tj d||j#dyy)aTShould we now try to autorenew the most recent cert version? This is a policy question and does not only depend on whether the cert is expired. (This considers whether autorenewal is enabled, whether the cert is revoked, and whether the time interval for autorenewal has been reached.) Note that this examines the numerically most recent cert version, not the currently deployed version. :returns: whether an attempt should now be made to autorenew the most current cert version in this lineage :rtype: bool z%Should renew, certificate is revoked.TrXrz8Should renew, less than %s before certificate expiry %s.z%Y-%m-%d %H:%M:%S %ZF)r_r\r<rbrcrr@rrrrrUdatetimenowrKrLrNstrftime)rrmrEexpiryrbs r,should_autorenewzRenewableCert.should_autorenews  & & (  !;!;!=> DE )99:OP ))--.CEUVH ))$,,224+67F##''1C)#x88 *+3#__-CDFr.r|rrr c  |j|j|jfD]N}tjj |r#t j|dtjd|Ptj|j|\}}tjj|jt} tjj | s t| dt|}t!d||} t#||} tjj | r\tjj%| rtj&| r(|j)t+j,d|ztjj | r\tjj%| rtj&| r(|j)t+j,d|z| | fD]M}tjj |r#t j|tjd|Ot.D cic]&} | tjj| | dz(} } t.D cic]&} | tjj| | d z(}} t.D]+} tj0t3|| | | | | -t5| d d 5}tjd | d |j7|dddtj8|d d t:5}tjd| d |j7|dddt5| dd 5}tjd| d|j7|dddt5| dd 5}tjd| d|j7||zdddtjj| t}t||j)t=|}t?||| | |}||j@|Scc} wcc} w#1swYYxYw#1swYxYw#1swYxYw#1swYxYw)aCreate a new certificate lineage. Attempts to create a certificate lineage -- enrolled for potential future renewal -- with the (suggested) lineage name lineagename, and the associated cert, privkey, and chain (the associated fullchain will be created automatically). Optional configurator and renewalparams record the configuration that was originally used to obtain this cert, so that it can be reused later during automated renewal. Returns a new RenewableCert object referring to the created lineage. (The actual lineage name, as well as all the relevant file paths, will be available within this object.) :param str lineagename: the suggested name for this lineage (normally the current cert's first subject DNS name) :param str cert: the initial certificate version in PEM format :param str privkey: the private key in PEM format :param str chain: the certificate chain in PEM format :param .NamespaceConfig cli_config: parsed command line arguments :returns: the newly-created RenewalCert object :rtype: :class:`storage.renewableCert` izCreating directory %s.T)rNzarchive directory exists for zlive directory exists for .pemz1.pemrrZWriting certificate to %s.rrizWriting private key to %s.r Writing chain to %s.r!Writing full chain to %s.)!r)rrrr'r2rmakedirsrbrcrunique_lineage_namer(r"rrrrisdirr.closerr3r^rrrdrj safe_openBASE_PRIVKEY_MODErrprK)clsr|rrr rsi config_filerbase_readme_patharchiverrkrRarchive_targetf_bf_arr new_configs r, new_lineagezRenewableCert.new_lineage s>00*2P2P%%' :A77>>!$##Au- 5q9  : (,'?'?  * *K(9$ _77<< (;(;VDww~~./ !"2 E /? #D*kB":{; 77>>' "BGGMM',BbjjQXFY    ))/+=? ? 77>>( #RWW]]8-D S[H\    )),{:< <8$ :A77>>!$##A& 5q9 : KSS$$ Xtf}==SSRZ[$$ WdWn EE[[ ]D JJ).*>t MvVZ| \ ] &.$ ' 3 LL5vf~ F IIdO ^^N95tCT U Y\ LL5vi7H I IIg  &/4 ( C LL/ A IIe  &%t , $ LL4f[6I J IIdUl #  $ggll8V4 k* !,)/?G F :&& 33AT[       $ $s<(+R+R  +R+R!+R)#.R5RR&)R25R>ct|jdd5}t|jdt }t t ttf|cdddS#1swYyxYw)NrrR)datapasswordbackend) rdrrrTr rr rr )r priv_key_filekeys r, _private_keyzRenewableCert._private_keyjsh $$$Y/ 6 L-&"'')')C m-DDEsK  L L Ls AA%%A.cF|j}t|tryy)zc :returns: The type of algorithm for the private, RSA or ECDSA :rtype: str RSAECDSA)r isinstancerrrs r,private_key_typezRenewableCert.private_key_typess" ! c= )r.c\|j}t|tr |jSy)z[ :returns: If the private key is an RSA key, its size. :rtype: int N)rrrkey_sizers r, rsa_key_sizezRenewableCert.rsa_key_size~s) ! c= )<< r.cp|j}t|tr|jjSy)zm :returns: If the private key is an elliptic key, the name of its curve. :rtype: str N)rrr curvenamers r,elliptic_curvezRenewableCert.elliptic_curves. ! c2 399>> !r. prior_versionnew_cert new_privkey new_chainc ||_|j}tDcic]=}|tjj |j dj||?}}tjj |j dj|} |ktjj| rtj| } nd|d} tjd| tj| |dntj|ddt 5} tjd |d| j#|dddtj$| t } tj&| |d| d d t)|d d5} tjd|d | j#|dddt)|dd5} tjd|d| j#|dddt)|dd5} tjd|d| j#||zdddtDcic]}||j*|} }t-|j.|j | ||_t3|j0|_|Scc}w#1swYsxYw#1swYxYw#1swYxYw#1swYxYwcc}w)aSave new cert and chain as a successor of a prior version. Returns the new version number that was created. .. note:: this function does NOT update links to deploy this version :param int prior_version: the old version to which this version is regarded as a successor (used to choose a privkey, if the key has not changed, but otherwise this information is not permanently recorded anywhere) :param bytes new_cert: the new certificate, in PEM format :param bytes new_privkey: the new private key, in PEM format, or ``None``, if the private key has not changed :param bytes new_chain: the new chain, in PEM format :param .NamespaceConfig cli_config: parsed command line arguments :returns: the new version number that was created :rtype: int r+zprivkey{0}.pemNrrgz'Writing symlink to old private key, %s.rZrizWriting new private key to %s.FT) copy_user copy_grouprrhr rjr!rk)rsr?r^rr'r(rQrrrrrbrcrrrprqrjcompute_private_key_modecopy_ownership_and_apply_moderdrrr|rrC) rrrrrrstarget_versionrkrR old_privkeyromodesymlinkss r,save_successorzRenewableCert.save_successors<%//1&( T%5%5|7J7J4Q_7`aa((ggll   .55mDF  ww~~k*(11+> ' d; LLBK P JJ{F9$5 6y 14?PQ %UV =vi?PQ $ % 66{DUVD  4 4VI.RV X&.$ ' 1 LL5vf~ F GGH  &/4 ( A LL/ A GGI  &%t , * LL4f[6I J GGHy( ) *@HHtD$,,T22HH.   d..*F1$//B[(& % %     * *Is<AK)+K"+K$+K&.K+$K7KKK(+K4c||_tDcic]}||j|}}t|j|j |||_t|j |_ycc}w)zSave only the config information without writing the new cert. :param .NamespaceConfig cli_config: parsed command line arguments N)rsr^rrr|rQrrC)rrsrkrs r,save_new_config_valuesz$RenewableCert.save_new_config_valuessg %?GHtD$,,T22HH.   d..*F1$//B IsA+num_prior_certs_to_keepc|j}t|jd}|tt||dz |z dz}|j}|D]~}t j d||tD]\}tjj|||d} tjj|rtj|^y #t$rt j d|dYwxYw) aQDelete unused historical certificate, chain and key items from the lineage. A certificate version will be deleted if it is: 1. not the current target, and 2. not a previous version within num_prior_certs_to_keep. :param num_prior_certs_to_keep: How many prior certificate versions to keep. rrz8Deleting %s/cert%d.pem and related items during clean uprgzFailed to clean up %sT)exc_infoN)r<rr2rangerQrbrcr^rr'r(r2r~rx)rrr'versions_to_deletervverrk item_paths r,truncatezRenewableCert.truncates446 !8!8!@Ac%(7!(;>U(UWY#[\ \""& TC LLS # '  TGGLLTF3%t2DE Tww~~i0 ),  T TTLL!8)dLSTs!4C!C>=C>F)r$N))<__name__ __module__ __qualname____doc__rZrNamespaceConfigboolrpropertyrrrrr|rarrQrr rrrrrrrrr rrrr$r'rUr2r5r<r?rDrArMrCrUr\r_re classmethodbytesr{r rr rrrrrrrrr.r,rrs!F*/449V9V4"&4374l#3C!S!! /x00 / //S// ?c?c?G GGd H4HH P 'BTBH $ !DsCx$9 ! &%3%8C=%(CHSM6GCG#G#G.BsBtCyB0 2S 2S 2 Ps P K3 K  ??(CCC#C$C4 3 4 ( =tCy =CD8 J J#$#J]4c]4]4]4u]4 - = =]4BQ]4]4~LeM3J$JKL#hsm MCM5MuM"'M5B5R5RMWZM^ C1N1N CSW CTTDTr.rrr)Qrrar&loggingrrretypingrrrrrrr r r r;cryptography.hazmat.backendsr ,cryptography.hazmat.primitives.asymmetric.ecr -cryptography.hazmat.primitives.asymmetric.rsar,cryptography.hazmat.primitives.serializationr parsedatetimerKr\rrrrrrrrrcertbot._internal.pluginsrrcertbot.compatrrcertbot.pluginsrr certbot.utilr getLoggerrrbr^r"r]rrqrrZr-r4r>r<rCCalendarrNrpr{rrrrrrrrurrrrrrr.r,rs%  8PGM !'+<%4,   8 $ 4 %g&9&9: }<< c m&C&CsWZ YM$A$A Yc YVY Y-*G*G!H'11G>Q>Q4n-S-C-&3&C&C-HL-&\c\\WSRUXEV\%2%B%B\GPGZGZ\:#####,MsMM$M* K(3- K K K M99d38n<=c=c=K]-J-JK25K:=KDCDCDCD E)"5"5 E=C`C` E#& E+. E: = =:C:TW: @:66@:#@:$@:Fd TJ,,d Tr.