Azure-Dest: Working Plugin

This commit is contained in:
sirferl 2020-11-14 12:49:14 +01:00
parent 40057262e1
commit 62230228a7
2 changed files with 12 additions and 3 deletions

View File

@ -14,12 +14,14 @@ import re
from flask import current_app from flask import current_app
from lemur.common.defaults import common_name, country, state, location, organizational_unit, organization 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 DestinationPlugin
from lemur.plugins.bases import SourcePlugin from lemur.plugins.bases import SourcePlugin
from cryptography.hazmat.primitives import serialization
import requests import requests
import json import json
import sys
import base64 import base64
@ -163,7 +165,13 @@ class AzureDestinationPlugin(DestinationPlugin):
post_header = { post_header = {
"Authorization" : f"Bearer {access_token}" "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}") current_app.logger.debug(f"AZURE: encoded certificate: {cert_package}")
post_body = { post_body = {

View File

@ -157,7 +157,8 @@ setup(
'adcs_issuer = lemur.plugins.lemur_adcs.plugin:ADCSIssuerPlugin', 'adcs_issuer = lemur.plugins.lemur_adcs.plugin:ADCSIssuerPlugin',
'adcs_source = lemur.plugins.lemur_adcs.plugin:ADCSSourcePlugin', 'adcs_source = lemur.plugins.lemur_adcs.plugin:ADCSSourcePlugin',
'entrust_issuer = lemur.plugins.lemur_entrust.plugin:EntrustIssuerPlugin', '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=[ classifiers=[