Last fixes

This commit is contained in:
Adrien Ferrand 2022-01-19 23:09:06 +01:00
parent 7eb6bbae82
commit 791667216c
6 changed files with 26 additions and 23 deletions

View file

@ -177,7 +177,7 @@ class KeyAuthorizationChallenge(_TokenChallenge, metaclass=abc.ABCMeta):
"""Generate Key Authorization.
:param JWK account_key:
:rtype unicode:
:rtype str:
"""
return self.encode("token") + "." + jose.b64encode(
@ -238,7 +238,7 @@ class DNS01Response(KeyAuthorizationChallengeResponse):
around `KeyAuthorizationChallengeResponse.verify`.
:param challenges.DNS01 chall: Corresponding challenge.
:param unicode domain: Domain name being verified.
:param str domain: Domain name being verified.
:param JWK account_public_key: Public key for the key pair
being authorized.
@ -266,7 +266,7 @@ class DNS01(KeyAuthorizationChallenge):
"""Generate validation.
:param JWK account_key:
:rtype: string
:rtype: str
"""
return jose.b64encode(hashlib.sha256(self.key_authorization(
@ -276,7 +276,7 @@ class DNS01(KeyAuthorizationChallenge):
"""Domain name for TXT validation record.
:param str name: Domain name being validated.
:rtype: string
:rtype: str
"""
return "{0}.{1}".format(self.LABEL, name)
@ -303,7 +303,7 @@ class HTTP01Response(KeyAuthorizationChallengeResponse):
"""Simple verify.
:param challenges.SimpleHTTP chall: Corresponding challenge.
:param unicode domain: Domain name being verified.
:param str domain: Domain name being verified.
:param JWK account_public_key: Public key for the key pair
being authorized.
:param int port: Port used in the validation.
@ -367,7 +367,7 @@ class HTTP01(KeyAuthorizationChallenge):
def path(self) -> str:
"""Path (starting with '/') for provisioned resource.
:rtype: string
:rtype: str
"""
return '/' + self.URI_ROOT_PATH + '/' + self.encode('token')
@ -378,8 +378,8 @@ class HTTP01(KeyAuthorizationChallenge):
Forms an URI to the HTTPS server provisioned resource
(containing :attr:`~SimpleHTTP.token`).
:param unicode domain: Domain name being verified.
:rtype: string
:param str domain: Domain name being verified.
:rtype: str
"""
return "http://" + domain + self.path
@ -388,7 +388,7 @@ class HTTP01(KeyAuthorizationChallenge):
"""Generate validation.
:param JWK account_key:
:rtype: string
:rtype: str
"""
return self.key_authorization(account_key)
@ -419,7 +419,7 @@ class TLSALPN01Response(KeyAuthorizationChallengeResponse):
) -> Tuple[crypto.X509, crypto.PKey]:
"""Generate tls-alpn-01 certificate.
:param unicode domain: Domain verified by the challenge.
:param str domain: Domain verified by the challenge.
:param OpenSSL.crypto.PKey key: Optional private key used in
certificate generation. If not provided (``None``), then
fresh key will be generated.
@ -443,8 +443,8 @@ class TLSALPN01Response(KeyAuthorizationChallengeResponse):
port: Optional[int] = None) -> crypto.X509:
"""Probe tls-alpn-01 challenge certificate.
:param unicode domain: domain being validated, required.
:param string host: IP address used to probe the certificate.
:param str domain: domain being validated, required.
:param str host: IP address used to probe the certificate.
:param int port: Port used to probe the certificate.
"""
@ -460,7 +460,7 @@ class TLSALPN01Response(KeyAuthorizationChallengeResponse):
def verify_cert(self, domain: str, cert: crypto.X509) -> bool:
"""Verify tls-alpn-01 challenge certificate.
:param unicode domain: Domain name being validated.
:param str domain: Domain name being validated.
:param OpensSSL.crypto.X509 cert: Challenge certificate.
:returns: Whether the certificate was successfully verified.
@ -615,7 +615,7 @@ class DNS(_TokenChallenge):
def validation_domain_name(self, name: str) -> str:
"""Domain name for TXT validation record.
:param unicode name: Domain name being validated.
:param str name: Domain name being validated.
"""
return "{0}.{1}".format(self.LABEL, name)

View file

@ -278,7 +278,7 @@ def _pyopenssl_cert_or_req_san(cert_or_req: Union[crypto.X509, crypto.X509Req])
:type cert_or_req: `OpenSSL.crypto.X509` or `OpenSSL.crypto.X509Req`.
:returns: A list of Subject Alternative Names that is DNS.
:rtype: `list` of `unicode`
:rtype: `list` of `str`
"""
# This function finds SANs with dns name
@ -300,7 +300,7 @@ def _pyopenssl_cert_or_req_san_ip(cert_or_req: Union[crypto.X509, crypto.X509Req
:type cert_or_req: `OpenSSL.crypto.X509` or `OpenSSL.crypto.X509Req`.
:returns: A list of Subject Alternative Names that are IP Addresses.
:rtype: `list` of `unicode`. note that this returns as string, not IPaddress object
:rtype: `list` of `str`. note that this returns as string, not IPaddress object
"""
@ -320,7 +320,7 @@ def _pyopenssl_extract_san_list_raw(cert_or_req: Union[crypto.X509, crypto.X509R
:type cert_or_req: `OpenSSL.crypto.X509` or `OpenSSL.crypto.X509Req`.
:returns: raw san strings, parsed byte as utf-8
:rtype: `list` of `unicode`
:rtype: `list` of `str`
"""
# This function finds SANs by dumping the certificate/CSR to text and
@ -352,7 +352,7 @@ def gen_ss_cert(key: crypto.PKey, domains: Optional[List[str]] = None,
) -> crypto.X509:
"""Generate new self-signed certificate.
:type domains: `list` of `unicode`
:type domains: `list` of `str`
:param OpenSSL.crypto.PKey key:
:param bool force_san:
:param extensions: List of additional extensions to include in the cert.

View file

@ -25,7 +25,7 @@ from acme import util
from acme.mixins import ResourceMixin
if TYPE_CHECKING:
from typing_extensions import Protocol
from typing_extensions import Protocol # pragma: no cover
else:
Protocol = object
@ -207,6 +207,9 @@ class Identifier(jose.JSONObjectWithFields):
class HasResourceType(Protocol):
"""
Represents a class with a resource_type class parameter of type string.
"""
resource_type: str = NotImplemented

View file

@ -1191,7 +1191,7 @@ class NginxConfigurator(common.Configurator):
self._chall_out += len(achalls)
responses: List[Optional[challenges.ChallengeResponse]] = [None] * len(achalls)
http_doer = http_01.NginxHttp01(self)
key_achalls = [achall for achall in achalls
if isinstance(achall, achallenges.KeyAuthorizationAnnotatedChallenge)]

View file

@ -1,7 +1,6 @@
"""Very low-level nginx config parser based on pyparsing."""
# Forked from https://github.com/fatiherikli/nginxparser (MIT Licensed)
import copy
from distutils.log import error
import logging
import typing
from typing import Any
@ -168,7 +167,7 @@ class UnspacedList(List[Any]):
inbound = UnspacedList(inbound)
return inbound, inbound.spaced
def insert(self, i: SupportsIndex, x: Any) -> None:
def insert(self, i: "SupportsIndex", x: Any) -> None:
"""Insert object before index."""
if not isinstance(i, int):
raise ValueError("Only integers are supported")

View file

@ -2,10 +2,11 @@
import datetime
import logging
import time
from typing import Dict, Sequence
from typing import Dict
from typing import Iterable
from typing import List
from typing import Optional
from typing import Sequence
from typing import Tuple
from typing import Type