Skip to content

Commit

Permalink
suppress warning on private key create. Fixes #1725
Browse files Browse the repository at this point in the history
  • Loading branch information
jay0lee committed Dec 4, 2024
1 parent 4c78c5f commit 0b303ff
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/gam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 0b303ff

Please sign in to comment.