From 2b65ab8972613b93e2314cddd265b2db4f96142f Mon Sep 17 00:00:00 2001 From: sirferl Date: Fri, 4 Dec 2020 13:54:39 +0100 Subject: [PATCH 1/2] Corrected delivery of TLS format --- lemur/plugins/lemur_kubernetes/plugin.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lemur/plugins/lemur_kubernetes/plugin.py b/lemur/plugins/lemur_kubernetes/plugin.py index 79207636..b8ea3d1b 100644 --- a/lemur/plugins/lemur_kubernetes/plugin.py +++ b/lemur/plugins/lemur_kubernetes/plugin.py @@ -10,6 +10,7 @@ .. moduleauthor:: Mikhail Khodorovskiy """ +import base64 import itertools import os @@ -17,7 +18,7 @@ import requests from flask import current_app from lemur.common.defaults import common_name -from lemur.common.utils import parse_certificate, base64encode +from lemur.common.utils import parse_certificate from lemur.plugins.bases import DestinationPlugin DEFAULT_API_VERSION = "v1" @@ -72,6 +73,12 @@ def _resolve_uri(k8s_base_uri, namespace, kind, name=None, api_ver=DEFAULT_API_V ) +# Performs Base64 encoding of string to string using the base64.b64encode() function +# which encodes bytes to bytes. +def base64encode(string): + return base64.b64encode(string.encode()).decode() + + def build_secret(secret_format, secret_name, body, private_key, cert_chain): secret = { "apiVersion": "v1", @@ -89,7 +96,7 @@ def build_secret(secret_format, secret_name, body, private_key, cert_chain): if secret_format == "TLS": secret["type"] = "kubernetes.io/tls" secret["data"] = { - "tls.crt": base64encode(body), + "tls.crt": base64encode("%s\n%s" % (body, cert_chain)), "tls.key": base64encode(private_key), } if secret_format == "Certificate": From a02b3789881629f34084a68cb92b95c4b14a7927 Mon Sep 17 00:00:00 2001 From: sirferl Date: Fri, 4 Dec 2020 14:12:21 +0100 Subject: [PATCH 2/2] Removed local base64encode and use common.utils version --- lemur/plugins/lemur_kubernetes/plugin.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/lemur/plugins/lemur_kubernetes/plugin.py b/lemur/plugins/lemur_kubernetes/plugin.py index b8ea3d1b..66d5fbe8 100644 --- a/lemur/plugins/lemur_kubernetes/plugin.py +++ b/lemur/plugins/lemur_kubernetes/plugin.py @@ -10,7 +10,6 @@ .. moduleauthor:: Mikhail Khodorovskiy """ -import base64 import itertools import os @@ -18,7 +17,7 @@ import requests from flask import current_app from lemur.common.defaults import common_name -from lemur.common.utils import parse_certificate +from lemur.common.utils import parse_certificate, base64encode from lemur.plugins.bases import DestinationPlugin DEFAULT_API_VERSION = "v1" @@ -73,12 +72,6 @@ def _resolve_uri(k8s_base_uri, namespace, kind, name=None, api_ver=DEFAULT_API_V ) -# Performs Base64 encoding of string to string using the base64.b64encode() function -# which encodes bytes to bytes. -def base64encode(string): - return base64.b64encode(string.encode()).decode() - - def build_secret(secret_format, secret_name, body, private_key, cert_chain): secret = { "apiVersion": "v1",