From 0b303ffc30b7889c7ac9f72c9a06abae9d4cbe40 Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Wed, 4 Dec 2024 03:00:09 +0000 Subject: [PATCH] suppress warning on private key create. Fixes #1725 --- src/gam/__init__.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/gam/__init__.py b/src/gam/__init__.py index e8b9317e1..229ece503 100755 --- a/src/gam/__init__.py +++ b/src/gam/__init__.py @@ -12418,9 +12418,16 @@ def _generatePrivateKeyAndPublicCert(projectId, clientEmail, name, key_size, b64 writeStdout(Msg.EXTRACTING_PUBLIC_CERTIFICATE+'\n') public_key = private_key.public_key() builder = x509.CertificateBuilder() - builder = builder.subject_name(x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, name, _validate=False)])) - builder = builder.issuer_name(x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, name, _validate=False)])) - # Gooogle seems to enforce the not before date strictly. Set the not before + # suppress cryptography warnings on service account email length + with warnings.catch_warnings(): + warnings.filterwarnings('ignore', message='.*Attribute\'s length.*') + builder = builder.subject_name(x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, + name, + _validate=False)])) + builder = builder.issuer_name(x509.Name([x509.NameAttribute(NameOID.COMMON_NAME, + name, + _validate=False)])) + # Google seems to enforce the not before date strictly. Set the not before # date to be UTC two minutes ago which should cover any clock skew. now = datetime.datetime.utcnow() builder = builder.not_valid_before(now - datetime.timedelta(minutes=2))