From d67b6c61206d3ccde2af7ebcab2d642d9a340c59 Mon Sep 17 00:00:00 2001 From: kevgliss Date: Sun, 8 Jan 2017 17:27:50 -0800 Subject: [PATCH] Chains are not always a given. (#645) --- lemur/plugins/lemur_java/plugin.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lemur/plugins/lemur_java/plugin.py b/lemur/plugins/lemur_java/plugin.py index 247ffeb4..771f3108 100644 --- a/lemur/plugins/lemur_java/plugin.py +++ b/lemur/plugins/lemur_java/plugin.py @@ -102,10 +102,14 @@ def create_keystore(cert, chain, jks_tmp, key, alias, passphrase): if isinstance(key, bytes): key = key.decode('utf-8') + # Create PKCS12 keystore from private key and public certificate with mktempfile() as cert_tmp: with open(cert_tmp, 'w') as f: - f.writelines([key.strip() + "\n", cert.strip() + "\n", chain.strip() + "\n"]) + if chain: + f.writelines([key.strip() + "\n", cert.strip() + "\n", chain.strip() + "\n"]) + else: + f.writelines([key.strip() + "\n", cert.strip() + "\n"]) with mktempfile() as p12_tmp: run_process([