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:
		| @@ -410,14 +410,16 @@ class RefstackClient: | |||||||
|                                      private_key_file) |                                      private_key_file) | ||||||
|                     self.logger.exception(e) |                     self.logger.exception(e) | ||||||
|                     return |                     return | ||||||
|             signer = private_key.signer(padding.PKCS1v15(), hashes.SHA256()) |             signature = private_key.sign( | ||||||
|             signer.update(data.encode('utf-8')) |                 data.encode('utf-8'), | ||||||
|             signature = binascii.b2a_hex(signer.finalize()) |                 padding.PKCS1v15(), | ||||||
|  |                 hashes.SHA256() | ||||||
|  |             ) | ||||||
|             pubkey = private_key.public_key().public_bytes( |             pubkey = private_key.public_key().public_bytes( | ||||||
|                 serialization.Encoding.OpenSSH, |                 serialization.Encoding.OpenSSH, | ||||||
|                 serialization.PublicFormat.OpenSSH) |                 serialization.PublicFormat.OpenSSH) | ||||||
|  |  | ||||||
|             headers['X-Signature'] = signature |             headers['X-Signature'] = binascii.b2a_hex(signature) | ||||||
|             headers['X-Public-Key'] = pubkey |             headers['X-Public-Key'] = pubkey | ||||||
|         try: |         try: | ||||||
|             response = requests.post(endpoint, |             response = requests.post(endpoint, | ||||||
| @@ -709,10 +711,12 @@ class RefstackClient: | |||||||
|                 serialization.Encoding.OpenSSH, |                 serialization.Encoding.OpenSSH, | ||||||
|                 serialization.PublicFormat.OpenSSH) |                 serialization.PublicFormat.OpenSSH) | ||||||
|  |  | ||||||
|         signer = private_key.signer(padding.PKCS1v15(), hashes.SHA256()) |         signature = private_key.sign( | ||||||
|         signer.update('signature'.encode('utf-8')) |             'signature'.encode('utf-8'), | ||||||
|         signature = binascii.b2a_hex(signer.finalize()) |             padding.PKCS1v15(), | ||||||
|         return pub_key, signature |             hashes.SHA256() | ||||||
|  |         ) | ||||||
|  |         return pub_key, binascii.b2a_hex(signature) | ||||||
|  |  | ||||||
|     def self_sign(self): |     def self_sign(self): | ||||||
|         """Generate signature for public key.""" |         """Generate signature for public key.""" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Thierry Carrez
					Thierry Carrez