From e5247ced5e08bd797ce79c5a07a9fbd0d0cfe54c Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Wed, 23 Dec 2015 18:32:20 -0500 Subject: [PATCH 1/2] Include the python version being used in the user agent for ACME requests. --- acme/acme/client.py | 5 ++++- letsencrypt/client.py | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/acme/acme/client.py b/acme/acme/client.py index c3e28ef47..cc90b7866 100644 --- a/acme/acme/client.py +++ b/acme/acme/client.py @@ -2,6 +2,7 @@ import datetime import heapq import logging +import platform import time import six @@ -483,6 +484,8 @@ class Client(object): # pylint: disable=too-many-instance-attributes 'Successful revocation must return HTTP OK status') +DEFAULT_USER_AGENT = 'acme-python Python/%s' % platform.python_version() + class ClientNetwork(object): """Client network.""" JSON_CONTENT_TYPE = 'application/json' @@ -490,7 +493,7 @@ class ClientNetwork(object): REPLAY_NONCE_HEADER = 'Replay-Nonce' def __init__(self, key, alg=jose.RS256, verify_ssl=True, - user_agent='acme-python'): + user_agent=DEFAULT_USER_AGENT): self.key = key self.alg = alg self.verify_ssl = verify_ssl diff --git a/letsencrypt/client.py b/letsencrypt/client.py index 080ee7991..b7c4ccab8 100644 --- a/letsencrypt/client.py +++ b/letsencrypt/client.py @@ -1,6 +1,7 @@ """Let's Encrypt client API.""" import logging import os +import platform from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.asymmetric import rsa @@ -51,9 +52,13 @@ def _determine_user_agent(config): """ if config.user_agent is None: - ua = "LetsEncryptPythonClient/{0} ({1}) Authenticator/{2} Installer/{3}" + ua = ( + "LetsEncryptPythonClient/{0} ({1}) Authenticator/{2} Installer/{3}" + " Python/{4}" + ) ua = ua.format(letsencrypt.__version__, " ".join(le_util.get_os_info()), - config.authenticator, config.installer) + config.authenticator, config.installer, + platform.python_version()) else: ua = config.user_agent return ua From 5376c3074599bbbcf5f44b8fe9127a2f62490d80 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Tue, 5 Jan 2016 07:30:49 -0500 Subject: [PATCH 2/2] Revert changes to the acme directory Only send the Python version in the user agent for the letsencrypt tool. --- acme/acme/client.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/acme/acme/client.py b/acme/acme/client.py index cc90b7866..c3e28ef47 100644 --- a/acme/acme/client.py +++ b/acme/acme/client.py @@ -2,7 +2,6 @@ import datetime import heapq import logging -import platform import time import six @@ -484,8 +483,6 @@ class Client(object): # pylint: disable=too-many-instance-attributes 'Successful revocation must return HTTP OK status') -DEFAULT_USER_AGENT = 'acme-python Python/%s' % platform.python_version() - class ClientNetwork(object): """Client network.""" JSON_CONTENT_TYPE = 'application/json' @@ -493,7 +490,7 @@ class ClientNetwork(object): REPLAY_NONCE_HEADER = 'Replay-Nonce' def __init__(self, key, alg=jose.RS256, verify_ssl=True, - user_agent=DEFAULT_USER_AGENT): + user_agent='acme-python'): self.key = key self.alg = alg self.verify_ssl = verify_ssl