Azure-Dest: More Lint, derive keysize from cert, remove debug output

This commit is contained in:
sirferl 2020-11-15 10:28:21 +01:00
parent 48302b6acc
commit 1b5f17d8b8
1 changed files with 10 additions and 11 deletions

View File

@ -11,7 +11,7 @@
""" """
from flask import current_app from flask import current_app
from lemur.common.defaults import common_name from lemur.common.defaults import common_name, bitstrength
from lemur.common.utils import parse_certificate, parse_private_key from lemur.common.utils import parse_certificate, parse_private_key
from lemur.plugins.bases import DestinationPlugin from lemur.plugins.bases import DestinationPlugin
@ -168,20 +168,19 @@ class AzureDestinationPlugin(DestinationPlugin):
) )
key_pkcs8 = key_pkcs8.decode("utf-8").replace('\\n', '\n') key_pkcs8 = key_pkcs8.decode("utf-8").replace('\\n', '\n')
cert_package = f"{body}\n{key_pkcs8}" cert_package = f"{body}\n{key_pkcs8}"
current_app.logger.debug(f"AZURE: encoded certificate: {cert_package}")
post_body = { post_body = {
"value": cert_package, "value": cert_package,
"policy": { "policy": {
"key_props": { "key_props": {
"exportable": True, "exportable": True,
"kty": "RSA", "kty": "RSA",
"key_size": 2048, "key_size": bitstrength(cert),
"reuse_key": True "reuse_key": True
}, },
"secret_props":{ "secret_props": {
"contentType": "application/x-pem-file" "contentType": "application/x-pem-file"
} }
} }
} }
@ -189,4 +188,4 @@ class AzureDestinationPlugin(DestinationPlugin):
response = self.session.post(cert_url, headers=post_header, json=post_body) response = self.session.post(cert_url, headers=post_header, json=post_body)
except requests.exceptions.RequestException as e: except requests.exceptions.RequestException as e:
current_app.logger.exception(f"AZURE: Error for POST {e}") current_app.logger.exception(f"AZURE: Error for POST {e}")
treturn_value = handle_response(response) return_value = handle_response(response)