Adding plugin tests. (#385)
* Adding plugin tests. * Fixing some python 2/3 incompatibilities.
This commit is contained in:
parent
a8040777b3
commit
300e2d0b7d
2
Makefile
2
Makefile
|
@ -60,7 +60,7 @@ test-js:
|
||||||
|
|
||||||
test-python:
|
test-python:
|
||||||
@echo "--> Running Python tests"
|
@echo "--> Running Python tests"
|
||||||
py.test lemur/tests || exit 1
|
py.test -v || exit 1
|
||||||
@echo ""
|
@echo ""
|
||||||
|
|
||||||
lint: lint-python lint-js
|
lint: lint-python lint-js
|
||||||
|
|
|
@ -111,7 +111,7 @@ def setup_acme_client():
|
||||||
key = current_app.config.get('ACME_PRIVATE_KEY').strip()
|
key = current_app.config.get('ACME_PRIVATE_KEY').strip()
|
||||||
acme_email = current_app.config.get('ACME_EMAIL')
|
acme_email = current_app.config.get('ACME_EMAIL')
|
||||||
acme_tel = current_app.config.get('ACME_TEL')
|
acme_tel = current_app.config.get('ACME_TEL')
|
||||||
acme_directory_url = current_app.config('ACME_DIRECTORY_URL'),
|
acme_directory_url = current_app.config.get('ACME_DIRECTORY_URL'),
|
||||||
contact = ('mailto:{}'.format(acme_email), 'tel:{}'.format(acme_tel))
|
contact = ('mailto:{}'.format(acme_email), 'tel:{}'.format(acme_tel))
|
||||||
|
|
||||||
key = serialization.load_pem_private_key(
|
key = serialization.load_pem_private_key(
|
||||||
|
@ -122,7 +122,7 @@ def setup_acme_client():
|
||||||
|
|
||||||
def acme_client_for_private_key(acme_directory_url, private_key):
|
def acme_client_for_private_key(acme_directory_url, private_key):
|
||||||
return Client(
|
return Client(
|
||||||
acme_directory_url, key=acme.jose.JWKRSA(key=private_key)
|
acme_directory_url, key=jose.JWKRSA(key=private_key)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,4 +2,3 @@
|
||||||
def test_get_certificates(app):
|
def test_get_certificates(app):
|
||||||
from lemur.plugins.base import plugins
|
from lemur.plugins.base import plugins
|
||||||
p = plugins.get('acme-issuer')
|
p = plugins.get('acme-issuer')
|
||||||
p.create_certificate('', {})
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ def get_all_server_certs(account_number):
|
||||||
result = response['list_server_certificates_response']['list_server_certificates_result']
|
result = response['list_server_certificates_response']['list_server_certificates_result']
|
||||||
|
|
||||||
for cert in result['server_certificate_metadata_list']:
|
for cert in result['server_certificate_metadata_list']:
|
||||||
certs.append(cert['arn'])
|
certs.append(cert['server_certificate_metadata']['arn'])
|
||||||
|
|
||||||
if result['is_truncated'] == 'true':
|
if result['is_truncated'] == 'true':
|
||||||
marker = result['marker']
|
marker = result['marker']
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
from moto import mock_iam, mock_sts
|
from moto import mock_iam, mock_sts
|
||||||
|
|
||||||
from lemur.certificates.models import Certificate
|
|
||||||
|
|
||||||
from lemur.tests.vectors import EXTERNAL_VALID_STR, PRIVATE_KEY_STR
|
from lemur.tests.vectors import EXTERNAL_VALID_STR, PRIVATE_KEY_STR
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,8 +13,7 @@ def test_get_name_from_arn():
|
||||||
@mock_iam()
|
@mock_iam()
|
||||||
def test_get_all_server_certs(app):
|
def test_get_all_server_certs(app):
|
||||||
from lemur.plugins.lemur_aws.iam import upload_cert, get_all_server_certs
|
from lemur.plugins.lemur_aws.iam import upload_cert, get_all_server_certs
|
||||||
cert = Certificate(EXTERNAL_VALID_STR)
|
upload_cert('123456789012', 'testCert', EXTERNAL_VALID_STR.decode('utf-8'), PRIVATE_KEY_STR.decode('utf-8'))
|
||||||
upload_cert('123456789012', cert, PRIVATE_KEY_STR)
|
|
||||||
certs = get_all_server_certs('123456789012')
|
certs = get_all_server_certs('123456789012')
|
||||||
assert len(certs) == 1
|
assert len(certs) == 1
|
||||||
|
|
||||||
|
@ -25,7 +22,6 @@ def test_get_all_server_certs(app):
|
||||||
@mock_iam()
|
@mock_iam()
|
||||||
def test_get_cert_from_arn(app):
|
def test_get_cert_from_arn(app):
|
||||||
from lemur.plugins.lemur_aws.iam import upload_cert, get_cert_from_arn
|
from lemur.plugins.lemur_aws.iam import upload_cert, get_cert_from_arn
|
||||||
cert = Certificate(EXTERNAL_VALID_STR)
|
upload_cert('123456789012', 'testCert', EXTERNAL_VALID_STR.decode('utf-8'), PRIVATE_KEY_STR.decode('utf-8'))
|
||||||
upload_cert('123456789012', cert, PRIVATE_KEY_STR)
|
body, chain = get_cert_from_arn('arn:aws:iam::123456789012:server-certificate/testCert')
|
||||||
body, chain = get_cert_from_arn('arn:aws:iam::123456789012:server-certificate/tttt2.netflixtest.net-NetflixInc-20150624-20150625')
|
assert body.replace('\n', '') == EXTERNAL_VALID_STR.decode('utf-8').replace('\n', '')
|
||||||
assert body.replace('\n', '') == EXTERNAL_VALID_STR.replace('\n', '')
|
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
from moto import mock_s3
|
|
||||||
import boto
|
|
||||||
|
|
||||||
|
|
||||||
@mock_s3()
|
|
||||||
def test_get_name_from_arn():
|
|
||||||
conn = boto.connect_s3()
|
|
||||||
conn.create_bucket('test')
|
|
||||||
from lemur.plugins.lemur_aws.s3 import write_to_s3
|
|
||||||
write_to_s3('11111111111111', 'test', 'key', 'body')
|
|
||||||
assert conn.get_bucket('test').get_key('key').get_contents_as_string() == 'body'
|
|
|
@ -1,7 +1,5 @@
|
||||||
from lemur.plugins.lemur_email.templates.config import env
|
from lemur.plugins.lemur_email.templates.config import env
|
||||||
|
|
||||||
import os.path
|
|
||||||
|
|
||||||
|
|
||||||
def test_render():
|
def test_render():
|
||||||
messages = [{
|
messages = [{
|
||||||
|
@ -12,5 +10,3 @@ def test_render():
|
||||||
|
|
||||||
template = env.get_template('{}.html'.format('expiration'))
|
template = env.get_template('{}.html'.format('expiration'))
|
||||||
body = template.render(dict(messages=messages, hostname='lemur.test.example.com'))
|
body = template.render(dict(messages=messages, hostname='lemur.test.example.com'))
|
||||||
with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'email.html'), 'w+') as f:
|
|
||||||
f.write(body.encode('utf8'))
|
|
||||||
|
|
|
@ -55,6 +55,12 @@ def split_chain(chain):
|
||||||
|
|
||||||
|
|
||||||
def create_truststore(cert, chain, jks_tmp, alias, passphrase):
|
def create_truststore(cert, chain, jks_tmp, alias, passphrase):
|
||||||
|
if isinstance(cert, bytes):
|
||||||
|
cert = cert.decode('utf-8')
|
||||||
|
|
||||||
|
if isinstance(chain, bytes):
|
||||||
|
chain = chain.decode('utf-8')
|
||||||
|
|
||||||
with mktempfile() as cert_tmp:
|
with mktempfile() as cert_tmp:
|
||||||
with open(cert_tmp, 'w') as f:
|
with open(cert_tmp, 'w') as f:
|
||||||
f.write(cert)
|
f.write(cert)
|
||||||
|
@ -88,10 +94,18 @@ def create_truststore(cert, chain, jks_tmp, alias, passphrase):
|
||||||
|
|
||||||
|
|
||||||
def create_keystore(cert, chain, jks_tmp, key, alias, passphrase):
|
def create_keystore(cert, chain, jks_tmp, key, alias, passphrase):
|
||||||
|
if isinstance(cert, bytes):
|
||||||
|
cert = cert.decode('utf-8')
|
||||||
|
|
||||||
|
if isinstance(chain, bytes):
|
||||||
|
chain = chain.decode('utf-8')
|
||||||
|
|
||||||
|
if isinstance(key, bytes):
|
||||||
|
key = key.decode('utf-8')
|
||||||
# Create PKCS12 keystore from private key and public certificate
|
# Create PKCS12 keystore from private key and public certificate
|
||||||
with mktempfile() as cert_tmp:
|
with mktempfile() as cert_tmp:
|
||||||
with open(cert_tmp, 'w') as f:
|
with open(cert_tmp, 'w') as f:
|
||||||
f.writelines([key + "\n", cert + "\n", chain + "\n"])
|
f.writelines([key, cert, chain])
|
||||||
|
|
||||||
with mktempfile() as p12_tmp:
|
with mktempfile() as p12_tmp:
|
||||||
run_process([
|
run_process([
|
||||||
|
|
|
@ -1,63 +1,21 @@
|
||||||
PRIVATE_KEY_STR = b"""
|
import pytest
|
||||||
-----BEGIN RSA PRIVATE KEY-----
|
from lemur.tests.vectors import INTERNAL_CERTIFICATE_A_STR, INTERNAL_PRIVAT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M/H7rw5BbvH0RZLOrzl46DDVzKTg
|
|
||||||
B1VOReAHsxBKFdkqeq1A99CLDow6vHTIEG8DwxkA7/2QPkt8MybwdApUyYnQh5/v
|
|
||||||
CxwkRt4Mm+EiYfn5iyL8yI+vaQSRToVO/3BND7MCgYAJQSpBJG8qzqPSR9kN1zRo
|
|
||||||
5/N60ULfSGUbV7U8rJNAlPGmw+EFA+SFt4xxmRBmIxMzyFSo2k8waiLeXmyVD2Go
|
|
||||||
CzhPaLXkXHmegajPYOelrCulTcXlRVMi/Z5LmaMhhCGDIyInwNUpSybROllQoJ2W
|
|
||||||
zSHTtODj/usz5U5U+WR4OQKBgHQRosI6t2wUo96peTS18UdnmP7GeZINBuymga5X
|
|
||||||
eJW+VLkxpuKBNOTW/lCYx+8Rlte7CyebP9oEa9VxtGgniTRKUeVy9lAm0bpMkt7K
|
|
||||||
QBNebvBKiVhX0DS3Q7U9UmpIFUfLlcXQTW0ERYFtYZTLQpeGvZ5LlyiaFDM34jM7
|
|
||||||
7WAXAoGANDPJdQLEuimCOAMx/xoecNWeZIP6ieB0hVBrwLNxsaZlkn1KodUMuvla
|
|
||||||
VEowbtPRdc9o3VZRh4q9cEakssTvOD70hgUZCFcMarmc37RgRvvD2fsZmDZF6qd3
|
|
||||||
QfHplREs9F0sW+eiirczG7up4XL+CA162TtZxW+2GAiQhwhE5jA=
|
|
||||||
-----END RSA PRIVATE KEY-----
|
|
||||||
"""
|
|
||||||
|
|
||||||
EXTERNAL_VALID_STR = b"""
|
|
||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIID2zCCAsOgAwIBAgICA+0wDQYJKoZIhvcNAQELBQAwgZcxCzAJBgNVBAYTAlVT
|
|
||||||
MRMwEQYDVQQIDApDYWxpZm9ybmlhMRIwEAYDVQQHDAlMb3MgR2F0b3MxDTALBgNV
|
|
||||||
BAMMBHRlc3QxFjAUBgNVBAoMDU5ldGZsaXgsIEluYy4xEzARBgNVBAsMCk9wZXJh
|
|
||||||
dGl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5Zo5pNjTUow0He
|
|
||||||
oe+V1hfYYvL1rocCmBOkhIGWz7622FxKDawRtZTGVsGsMwMIWyvS3+KQ04K8yHhp
|
|
||||||
bQOg9zZAoYQuHY1inKBnA0II8eW0hPpJrlZoSqN8Tp0NSBpFiUk3m7KNFP2kITIf
|
|
||||||
tTneAgyUsgfDxNDifZryZSzg7MH31sTBcYaotSmTXw==
|
|
||||||
-----END CERTIFICATE-----
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def test_export_certificate_to_jks(app):
|
def test_export_certificate_to_jks(app):
|
||||||
from lemur.plugins.base import plugins
|
from lemur.plugins.base import plugins
|
||||||
p = plugins.get('java-export')
|
p = plugins.get('java-truststore-jks')
|
||||||
options = {'passphrase': 'test1234'}
|
options = [{'name': 'passphrase', 'value': 'test1234'}]
|
||||||
raw = p.export(EXTERNAL_VALID_STR, "", PRIVATE_KEY_STR, options)
|
raw = p.export(INTERNAL_CERTIFICATE_A_STR, "", "", options)
|
||||||
|
assert raw != b""
|
||||||
|
|
||||||
|
|
||||||
|
def test_export_keystore(app):
|
||||||
|
from lemur.plugins.base import plugins
|
||||||
|
p = plugins.get('java-keystore-jks')
|
||||||
|
options = [{'name': 'passphrase', 'value': 'test1234'}]
|
||||||
|
with pytest.raises(Exception):
|
||||||
|
p.export(INTERNAL_CERTIFICATE_A_STR, "", "", options)
|
||||||
|
|
||||||
|
raw = p.export(INTERNAL_CERTIFICATE_A_STR, "", INTERNAL_PRIVATE_KEY_A_STR, options)
|
||||||
assert raw != b""
|
assert raw != b""
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
|
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
|
||||||
"""
|
"""
|
||||||
|
from io import open
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from flask import current_app
|
from flask import current_app
|
||||||
|
@ -43,6 +44,15 @@ def create_pkcs12(cert, chain, p12_tmp, key, alias, passphrase):
|
||||||
:param alias:
|
:param alias:
|
||||||
:param passphrase:
|
:param passphrase:
|
||||||
"""
|
"""
|
||||||
|
if isinstance(cert, bytes):
|
||||||
|
cert = cert.decode('utf-8')
|
||||||
|
|
||||||
|
if isinstance(chain, bytes):
|
||||||
|
chain = chain.decode('utf-8')
|
||||||
|
|
||||||
|
if isinstance(key, bytes):
|
||||||
|
key = key.decode('utf-8')
|
||||||
|
|
||||||
with mktempfile() as key_tmp:
|
with mktempfile() as key_tmp:
|
||||||
with open(key_tmp, 'w') as f:
|
with open(key_tmp, 'w') as f:
|
||||||
f.write(key)
|
f.write(key)
|
||||||
|
@ -50,7 +60,7 @@ def create_pkcs12(cert, chain, p12_tmp, key, alias, passphrase):
|
||||||
# Create PKCS12 keystore from private key and public certificate
|
# Create PKCS12 keystore from private key and public certificate
|
||||||
with mktempfile() as cert_tmp:
|
with mktempfile() as cert_tmp:
|
||||||
with open(cert_tmp, 'w') as f:
|
with open(cert_tmp, 'w') as f:
|
||||||
f.writelines([cert + "\n", chain + "\n"])
|
f.writelines([cert, chain])
|
||||||
|
|
||||||
run_process([
|
run_process([
|
||||||
"openssl",
|
"openssl",
|
||||||
|
@ -120,6 +130,9 @@ class OpenSSLExportPlugin(ExportPlugin):
|
||||||
|
|
||||||
with mktemppath() as output_tmp:
|
with mktemppath() as output_tmp:
|
||||||
if type == 'PKCS12 (.p12)':
|
if type == 'PKCS12 (.p12)':
|
||||||
|
if not key:
|
||||||
|
raise Exception("Private Key required by {0}".format(type))
|
||||||
|
|
||||||
create_pkcs12(body, chain, output_tmp, key, alias, passphrase)
|
create_pkcs12(body, chain, output_tmp, key, alias, passphrase)
|
||||||
extension = "p12"
|
extension = "p12"
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,63 +1,13 @@
|
||||||
PRIVATE_KEY_STR = b"""
|
import pytest
|
||||||
-----BEGIN RSA PRIVATE KEY-----
|
from lemur.tests.vectors import INTERNAL_PRIVATE_KEY_A_STR, INTERNAL_CERTIFICATE_A_STR
|
||||||
MIIEogIBAAKCAQEAsXn+QZRATxryRmGXI4fdI+0a2oBwuVh8fC/9bcqX6c5eDmgc
|
|
||||||
rj6esmc1hpIFxMM3DvkFXX6xISkU6B5fmYDEGZLi7NvcXF3+EoA/SCkP1MFlvqhn
|
|
||||||
EvNhb0t1fBLs0i/0gfTS/FHBZY1ekHisd/sUetCDZ7F11RxMwws0Oc8bl7j1TpRc
|
|
||||||
awXFAsh/aWwQOwFeyWU7TtZeAE7sMyWXInBg37tKk1wlv+mN+27WijI091+amkVy
|
|
||||||
zIV6mA5OHfqbjuqV8uQflN8jE244Qr7shtSk7LpBpWf0M6dC7dXbuUctHFhqcDjy
|
|
||||||
3IRUl+NisKRoMtq+a0uehfmpFNSUD7F4gdUtSwIDAQABAoIBAGITsZ+aBuPwVzzv
|
|
||||||
x286MMoeyL1BR4oVzU1v09Rtpf/uLGo3vMnKDzc19A12+rseynl6wi1FyysxIb2Y
|
|
||||||
s2oID9a2JrOQWLmus66TsuT01CvV6J0xQSzm1MyFXdqANuF84NlEa6hGoeK1+jFK
|
|
||||||
jr0LQukP+9484oovxnfu5CCiRHRWNZmeuekuYhI1SJf343Tr6jwvyr6KZpnIy0Yt
|
|
||||||
axuuIZdCfY9ZV2vFG89GwwgwVQrhf14Kv5vBMZrNh1lRGsr0Sqlx5cGkPRAy90lg
|
|
||||||
HjrRMogrtXr3AR5Pk2qqAYXzZBU2EFhJ3k2njpwOzlSj0r0ZwTmejZ89cco0sW5j
|
|
||||||
+eQ6aRECgYEA1tkNW75fgwU52Va5VETCzG8II/pZdqNygnoc3z8EutN+1w8f6Tr+
|
|
||||||
PdpKSICW0z7Iq4f5k/4wrA5xw1vy5RBMH0ZP29GwHTvCPiTBboR9vWvxQvZn1jb9
|
|
||||||
wvKa0RxE18KcF0YIyTnZMubkA17QTFlvCNyZg0iCqeyFYPyqVE+R4AkCgYEA03h1
|
|
||||||
XrqECZDDbG9HLUdGbkZNk4VzTcF6dQ3GAPY8M/H7rw5BbvH0RZLOrzl46DDVzKTg
|
|
||||||
B1VOReAHsxBKFdkqeq1A99CLDow6vHTIEG8DwxkA7/2QPkt8MybwdApUyYnQh5/v
|
|
||||||
CxwkRt4Mm+EiYfn5iyL8yI+vaQSRToVO/3BND7MCgYAJQSpBJG8qzqPSR9kN1zRo
|
|
||||||
5/N60ULfSGUbV7U8rJNAlPGmw+EFA+SFt4xxmRBmIxMzyFSo2k8waiLeXmyVD2Go
|
|
||||||
CzhPaLXkXHmegajPYOelrCulTcXlRVMi/Z5LmaMhhCGDIyInwNUpSybROllQoJ2W
|
|
||||||
zSHTtODj/usz5U5U+WR4OQKBgHQRosI6t2wUo96peTS18UdnmP7GeZINBuymga5X
|
|
||||||
eJW+VLkxpuKBNOTW/lCYx+8Rlte7CyebP9oEa9VxtGgniTRKUeVy9lAm0bpMkt7K
|
|
||||||
QBNebvBKiVhX0DS3Q7U9UmpIFUfLlcXQTW0ERYFtYZTLQpeGvZ5LlyiaFDM34jM7
|
|
||||||
7WAXAoGANDPJdQLEuimCOAMx/xoecNWeZIP6ieB0hVBrwLNxsaZlkn1KodUMuvla
|
|
||||||
VEowbtPRdc9o3VZRh4q9cEakssTvOD70hgUZCFcMarmc37RgRvvD2fsZmDZF6qd3
|
|
||||||
QfHplREs9F0sW+eiirczG7up4XL+CA162TtZxW+2GAiQhwhE5jA=
|
|
||||||
-----END RSA PRIVATE KEY-----
|
|
||||||
"""
|
|
||||||
|
|
||||||
EXTERNAL_VALID_STR = b"""
|
|
||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIID2zCCAsOgAwIBAgICA+0wDQYJKoZIhvcNAQELBQAwgZcxCzAJBgNVBAYTAlVT
|
|
||||||
MRMwEQYDVQQIDApDYWxpZm9ybmlhMRIwEAYDVQQHDAlMb3MgR2F0b3MxDTALBgNV
|
|
||||||
BAMMBHRlc3QxFjAUBgNVBAoMDU5ldGZsaXgsIEluYy4xEzARBgNVBAsMCk9wZXJh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xgXkKg+uMXOez5Zo5pNjTUow0He
|
|
||||||
oe+V1hfYYvL1rocCmBOkhIGWz7622FxKDawRtZTGVsGsMwMIWyvS3+KQ04K8yHhp
|
|
||||||
bQOg9zZAoYQuHY1inKBnA0II8eW0hPpJrlZoSqN8Tp0NSBpFiUk3m7KNFP2kITIf
|
|
||||||
tTneAgyUsgfDxNDifZryZSzg7MH31sTBcYaotSmTXw==
|
|
||||||
-----END CERTIFICATE-----
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
def test_export_certificate_to_jks(app):
|
def test_export_certificate_to_pkcs12(app):
|
||||||
from lemur.plugins.base import plugins
|
from lemur.plugins.base import plugins
|
||||||
p = plugins.get('java-export')
|
p = plugins.get('openssl-export')
|
||||||
options = {'passphrase': 'test1234'}
|
options = [{'name': 'passphrase', 'value': 'test1234'}, {'name': 'type', 'value': 'PKCS12 (.p12)'}]
|
||||||
raw = p.export(EXTERNAL_VALID_STR, "", PRIVATE_KEY_STR, options)
|
with pytest.raises(Exception):
|
||||||
|
p.export(INTERNAL_CERTIFICATE_A_STR, "", "", options)
|
||||||
|
|
||||||
|
raw = p.export(INTERNAL_CERTIFICATE_A_STR, "", INTERNAL_PRIVATE_KEY_A_STR, options)
|
||||||
assert raw != b""
|
assert raw != b""
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
|
|
||||||
def test_get_certificates(app):
|
def test_get_certificates(app):
|
||||||
from lemur.plugins.base import plugins
|
from lemur.plugins.base import plugins
|
||||||
p = plugins.get('verisign-source')
|
p = plugins.get('verisign-issuer')
|
||||||
p.get_certificates()
|
|
||||||
|
|
|
@ -190,6 +190,61 @@ XKxcRgm/Va4QMEAnec0qXfdTVJaJiAW0bdKwKRRrrbwcTdNRGibdng==
|
||||||
-----END RSA PRIVATE KEY-----
|
-----END RSA PRIVATE KEY-----
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
INTERNAL_CERTIFICATE_A_STR = b"""
|
||||||
|
-----BEGIN CERTIFICAT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vqBL6Yzf9dRI2li9XYmavxU7OK/KJtBo/Wnw3DVT5
|
||||||
|
jxYrn4YKJU9+T0hr57bWUQ7HjMNojwBcgglzPN9KOtfTfbPEUIeoRpCjeyjwBUSN
|
||||||
|
nrTDiYPV+XI4LAyDmuR7esSvm2+0h6C0dmUbVspkxBaKFEYUKIYaZbEFEBsyZGri
|
||||||
|
qDIyu9HSvu2MJ2lVxfMNsW+IYG74DOqJQsIFP+7hrfdPoMGm4GvAiHR1IuSmq+sf
|
||||||
|
L0Ew8hy0GG3nZ6uXLW7q
|
||||||
|
-----END CERTIFICATE-----
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
INTERNAL_PRIVATE_KEY_A_STR = b"""
|
||||||
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
|
MIIEpQIBAAKCAQEAtkyvL6EqSgYSJX11635Hb8FBG/8Wey6C2KtG7M+GXvGCsSmf
|
||||||
|
NqQMeZdfW9Avxelkstp5/K+ilVJJ2TJRelu1yVUUkQcrP7imgf7CxKQAnPz2oXQI
|
||||||
|
mLFbm7OS1zKA+qwtLGrId3vVQaotUtdI+wxx0YE66pyfOhQJsVOeuYwG8CCxnAj/
|
||||||
|
lXeNLA1tn39A8FLfj9nxjvZWWm2z8qXO2IYOWEMOOel1zixhypeJoTD2cJHDKNlU
|
||||||
|
nXN4q5ejpsD4ehLFXIPXsKJv5XOtNYB9UHB3moXlEOuKAquRzBOfTP+rUYyfbHmz
|
||||||
|
CN4eXekpR6vze49hlg8QdCNjVY6jHRrOuVKGuwIDAQABAoIBACYPnqfwGzc3S0Se
|
||||||
|
jCctx1Zy39grixMO4+y+3eEFdwWNoP7CNOagm6YrT5KIxeCpWQfqi3uRY/2PH7IE
|
||||||
|
SnSkfzDY3aFmAMaeE82iViHeJ+6e9hNBeaX/qaO5e1gIyFsN5aSXauFfbmf2Ut4v
|
||||||
|
6qHXuE/Ijnd7WdczZc6rKcGNlck+f/QtsZhYEYbgHT3Nrt0ztlvkdrc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+0vTSShrT5GftLCyMtOiYSHkGEvMOGFBuowzoz
|
||||||
|
3i841gR9+cwA0S1hy7fC0PDmTo0xC91JocwesPQ023MmECPfu6Frzog=
|
||||||
|
-----END RSA PRIVATE KEY-----
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
CSR_STR = b"""
|
CSR_STR = b"""
|
||||||
-----BEGIN CERTIFICATE REQUEST-----
|
-----BEGIN CERTIFICATE REQUEST-----
|
||||||
|
|
Loading…
Reference in New Issue