summaryrefslogtreecommitdiff
path: root/python/samba
diff options
context:
space:
mode:
authorJoseph Sutton <josephsutton@catalyst.net.nz>2023-07-05 12:53:45 +1200
committerAndrew Bartlett <abartlet@samba.org>2023-07-19 01:47:34 +0000
commit01196cc741ddf611794ba6eb1b5f3a0bcff2f0da (patch)
treece940354c073893a156db7020d556314996b789a /python/samba
parentce9786748b7b594ca0864158ba49ca4def1b593c (diff)
downloadsamba-01196cc741ddf611794ba6eb1b5f3a0bcff2f0da.tar.gz
samba-01196cc741ddf611794ba6eb1b5f3a0bcff2f0da.tar.bz2
samba-01196cc741ddf611794ba6eb1b5f3a0bcff2f0da.zip
tests/krb5: Factor out a method to fetch the CA certificate and private key
BUG: https://bugzilla.samba.org/show_bug.cgi?id=9612 Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'python/samba')
-rwxr-xr-xpython/samba/tests/krb5/pkinit_tests.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/python/samba/tests/krb5/pkinit_tests.py b/python/samba/tests/krb5/pkinit_tests.py
index 4a4d81fd877..2481d1df4a8 100755
--- a/python/samba/tests/krb5/pkinit_tests.py
+++ b/python/samba/tests/krb5/pkinit_tests.py
@@ -663,12 +663,7 @@ class PkInitTests(KDCBaseTest):
return kdc_exchange_dict
- def create_certificate(self, creds, certificate_signature=None):
- if certificate_signature is None:
- certificate_signature = hashes.SHA1
-
- user_name = creds.get_username()
-
+ def get_ca_cert_and_private_key(self):
# The password with which to try to encrypt the certificate or private
# key specified on the command line.
ca_pass = samba.tests.env_get_var_value('CA_PASS', allow_missing=True)
@@ -702,6 +697,16 @@ class PkInitTests(KDCBaseTest):
ca_private_key = serialization.load_pem_private_key(
f.read(), password=ca_pass, backend=default_backend())
+ return ca_cert, ca_private_key
+
+ def create_certificate(self, creds, certificate_signature=None):
+ if certificate_signature is None:
+ certificate_signature = hashes.SHA1
+
+ user_name = creds.get_username()
+
+ ca_cert, ca_private_key = self.get_ca_cert_and_private_key()
+
builder = x509.CertificateBuilder()
# Add the subject name.