suppress warning on private key create. Fixes #1725

This commit is contained in:
Jay Lee
2024-12-04 03:00:09 +00:00
parent 4c78c5fe9f
commit 0b303ffc30

View File

@@ -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))