Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Commit a8efb6b

Browse files
committed
simplified from_string
1 parent 6aa7f41 commit a8efb6b

1 file changed

Lines changed: 3 additions & 16 deletions

File tree

google/auth/crypt/rsa.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
from google.auth import _helpers
2323
from google.auth.crypt import base
24-
from google.auth.exceptions import MissingOptionalDependencyError
2524
from google.auth.crypt import _cryptography_rsa
2625
from google.auth.crypt import _python_rsa
2726

@@ -68,18 +67,12 @@ def from_string(cls, public_key):
6867
x509 public key certificate.
6968
7069
Returns:
71-
google.auth.crypt.RSAVerifier: The constructed verifier.
70+
google.auth.crypt.Verifier: The constructed verifier.
7271
7372
Raises:
7473
ValueError: If the public_key can't be parsed.
7574
"""
76-
try:
77-
instance = cls(None)
78-
except ValueError:
79-
# ignore exception when creating instnce without associated key
80-
pass
81-
instance._impl = _cryptography_rsa.RSAVerifier.from_string(public_key)
82-
return instance
75+
return _cryptography_rsa.RSAVerifier.from_string(public_key)
8376

8477

8578
class RSASigner(base.Signer, base.FromServiceAccountMixin):
@@ -136,10 +129,4 @@ def from_string(cls, key, key_id=None):
136129
ValueError: If the key cannot be parsed as PKCS#1 or PKCS#8 in
137130
PEM format.
138131
"""
139-
try:
140-
instance = cls(None)
141-
except ValueError:
142-
# ignore exception when creating instnce without associated key
143-
pass
144-
instance._impl = _cryptography_rsa.RSASigner.from_string(key, key_id=key_id)
145-
return instance
132+
return _cryptography_rsa.RSASigner.from_string(key, key_id=key_id)

0 commit comments

Comments
 (0)