Tests: TestApplicationTLS.openssl_conf() introduced.
This commit is contained in:
@@ -145,6 +145,8 @@ class TestTLS(TestApplicationTLS):
|
|||||||
def test_tls_certificate_key_ec(self):
|
def test_tls_certificate_key_ec(self):
|
||||||
self.load('empty')
|
self.load('empty')
|
||||||
|
|
||||||
|
self.openssl_conf()
|
||||||
|
|
||||||
subprocess.call(
|
subprocess.call(
|
||||||
[
|
[
|
||||||
'openssl',
|
'openssl',
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
import ssl
|
import ssl
|
||||||
import subprocess
|
import subprocess
|
||||||
from unit.applications.proto import TestApplicationProto
|
from unit.applications.proto import TestApplicationProto
|
||||||
@@ -12,6 +13,8 @@ class TestApplicationTLS(TestApplicationProto):
|
|||||||
self.context.verify_mode = ssl.CERT_NONE
|
self.context.verify_mode = ssl.CERT_NONE
|
||||||
|
|
||||||
def certificate(self, name='default', load=True):
|
def certificate(self, name='default', load=True):
|
||||||
|
self.openssl_conf()
|
||||||
|
|
||||||
subprocess.call(
|
subprocess.call(
|
||||||
[
|
[
|
||||||
'openssl',
|
'openssl',
|
||||||
@@ -59,13 +62,13 @@ class TestApplicationTLS(TestApplicationProto):
|
|||||||
|
|
||||||
return ssl.get_server_certificate(addr, ssl_version=ssl_version)
|
return ssl.get_server_certificate(addr, ssl_version=ssl_version)
|
||||||
|
|
||||||
def load(self, script, name=None):
|
def openssl_conf(self):
|
||||||
if name is None:
|
conf_path = self.testdir + '/openssl.conf'
|
||||||
name = script
|
|
||||||
|
|
||||||
# create default openssl configuration
|
if os.path.exists(conf_path):
|
||||||
|
return
|
||||||
|
|
||||||
with open(self.testdir + '/openssl.conf', 'w') as f:
|
with open(conf_path, 'w') as f:
|
||||||
f.write(
|
f.write(
|
||||||
"""[ req ]
|
"""[ req ]
|
||||||
default_bits = 2048
|
default_bits = 2048
|
||||||
@@ -74,6 +77,10 @@ distinguished_name = req_distinguished_name
|
|||||||
[ req_distinguished_name ]"""
|
[ req_distinguished_name ]"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def load(self, script, name=None):
|
||||||
|
if name is None:
|
||||||
|
name = script
|
||||||
|
|
||||||
script_path = self.current_dir + '/python/' + script
|
script_path = self.current_dir + '/python/' + script
|
||||||
|
|
||||||
self._load_conf(
|
self._load_conf(
|
||||||
|
|||||||
Reference in New Issue
Block a user