Remove warning about deprecated signer function
Use of signer/verifier functions has been deprecated since cryptography 2.0, and a deprecation warning is shown on every use of the 'refstack-client sign' command. Remove that warning by using the sign function instead of the signer function, as described in: https: //github.com/pyca/cryptography/blob/1.9/docs/hazmat/primitives/asymmetric/rsa.rst#signing Change-Id: Id9d5ed33b601771cd75df421a15ed2894fcd4d92
This commit is contained in:
parent
832b712812
commit
028d13d74b
@ -410,14 +410,16 @@ class RefstackClient:
|
||||
private_key_file)
|
||||
self.logger.exception(e)
|
||||
return
|
||||
signer = private_key.signer(padding.PKCS1v15(), hashes.SHA256())
|
||||
signer.update(data.encode('utf-8'))
|
||||
signature = binascii.b2a_hex(signer.finalize())
|
||||
signature = private_key.sign(
|
||||
data.encode('utf-8'),
|
||||
padding.PKCS1v15(),
|
||||
hashes.SHA256()
|
||||
)
|
||||
pubkey = private_key.public_key().public_bytes(
|
||||
serialization.Encoding.OpenSSH,
|
||||
serialization.PublicFormat.OpenSSH)
|
||||
|
||||
headers['X-Signature'] = signature
|
||||
headers['X-Signature'] = binascii.b2a_hex(signature)
|
||||
headers['X-Public-Key'] = pubkey
|
||||
try:
|
||||
response = requests.post(endpoint,
|
||||
@ -709,10 +711,12 @@ class RefstackClient:
|
||||
serialization.Encoding.OpenSSH,
|
||||
serialization.PublicFormat.OpenSSH)
|
||||
|
||||
signer = private_key.signer(padding.PKCS1v15(), hashes.SHA256())
|
||||
signer.update('signature'.encode('utf-8'))
|
||||
signature = binascii.b2a_hex(signer.finalize())
|
||||
return pub_key, signature
|
||||
signature = private_key.sign(
|
||||
'signature'.encode('utf-8'),
|
||||
padding.PKCS1v15(),
|
||||
hashes.SHA256()
|
||||
)
|
||||
return pub_key, binascii.b2a_hex(signature)
|
||||
|
||||
def self_sign(self):
|
||||
"""Generate signature for public key."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user