Skip to content

Commit

Permalink
Make CertificateGenerator not dependent on external config in OpenSSL…
Browse files Browse the repository at this point in the history
… 3.0
  • Loading branch information
bukka committed Aug 8, 2021
1 parent 69fb3ef commit c90c9c7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions ext/openssl/tests/CertificateGenerator.inc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ class CertificateGenerator
),
null,
$this->caKey,
2
2,
[
'config' => self::CONFIG,
]
);
}

Expand Down Expand Up @@ -101,6 +104,7 @@ class CertificateGenerator
[ req ]
distinguished_name = req_distinguished_name
default_md = sha256
default_bits = 1024
[ req_distinguished_name ]
Expand All @@ -124,8 +128,9 @@ CONFIG;
];

$this->lastKey = self::generateKey($keyLength);
$csr = openssl_csr_new($dn, $this->lastKey, $config);
$this->lastCert = openssl_csr_sign(
openssl_csr_new($dn, $this->lastKey, $config),
$csr,
$this->ca,
$this->caKey,
/* days */ 2,
Expand All @@ -139,7 +144,7 @@ CONFIG;
openssl_x509_export($this->lastCert, $certText);

$keyText = '';
openssl_pkey_export($this->lastKey, $keyText);
openssl_pkey_export($this->lastKey, $keyText, null, $config);

file_put_contents($file, $certText . PHP_EOL . $keyText);
} finally {
Expand Down

0 comments on commit c90c9c7

Please sign in to comment.