diff --git a/lemur/plugins/lemur_azure_dest/plugin.py b/lemur/plugins/lemur_azure_dest/plugin.py index 12d6e27e..ef4ffd42 100755 --- a/lemur/plugins/lemur_azure_dest/plugin.py +++ b/lemur/plugins/lemur_azure_dest/plugin.py @@ -14,12 +14,14 @@ import re from flask import current_app from lemur.common.defaults import common_name, country, state, location, organizational_unit, organization -from lemur.common.utils import parse_certificate +from lemur.common.utils import parse_certificate, parse_private_key from lemur.plugins.bases import DestinationPlugin from lemur.plugins.bases import SourcePlugin +from cryptography.hazmat.primitives import serialization import requests import json +import sys import base64 @@ -163,7 +165,13 @@ class AzureDestinationPlugin(DestinationPlugin): post_header = { "Authorization" : f"Bearer {access_token}" } - cert_package = f"{body}\n{private_key}" + key_pkcs8 = parse_private_key(private_key).private_bytes( + encoding=serialization.Encoding.PEM, + format=serialization.PrivateFormat.PKCS8, + encryption_algorithm=serialization.NoEncryption(), + ) + key_pkcs8 = key_pkcs8.decode("utf-8").replace('\\n', '\n') + cert_package = f"{body}\n{key_pkcs8}" current_app.logger.debug(f"AZURE: encoded certificate: {cert_package}") post_body = { diff --git a/setup.py b/setup.py index 59e35b53..b817cc63 100644 --- a/setup.py +++ b/setup.py @@ -157,7 +157,8 @@ setup( 'adcs_issuer = lemur.plugins.lemur_adcs.plugin:ADCSIssuerPlugin', 'adcs_source = lemur.plugins.lemur_adcs.plugin:ADCSSourcePlugin', 'entrust_issuer = lemur.plugins.lemur_entrust.plugin:EntrustIssuerPlugin', - 'entrust_source = lemur.plugins.lemur_entrust.plugin:EntrustSourcePlugin' + 'entrust_source = lemur.plugins.lemur_entrust.plugin:EntrustSourcePlugin', + 'azure_destination = lemur.plugins.lemur_azure_dest.plugin:AzureDestinationPlugin' ], }, classifiers=[