Skip to content

Commit c90c9c7

Browse files
committed
Make CertificateGenerator not dependent on external config in OpenSSL 3.0
1 parent 69fb3ef commit c90c9c7

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

ext/openssl/tests/CertificateGenerator.inc

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,10 @@ class CertificateGenerator
6565
),
6666
null,
6767
$this->caKey,
68-
2
68+
2,
69+
[
70+
'config' => self::CONFIG,
71+
]
6972
);
7073
}
7174

@@ -101,6 +104,7 @@ class CertificateGenerator
101104
[ req ]
102105
distinguished_name = req_distinguished_name
103106
default_md = sha256
107+
default_bits = 1024
104108
105109
[ req_distinguished_name ]
106110
@@ -124,8 +128,9 @@ CONFIG;
124128
];
125129

126130
$this->lastKey = self::generateKey($keyLength);
131+
$csr = openssl_csr_new($dn, $this->lastKey, $config);
127132
$this->lastCert = openssl_csr_sign(
128-
openssl_csr_new($dn, $this->lastKey, $config),
133+
$csr,
129134
$this->ca,
130135
$this->caKey,
131136
/* days */ 2,
@@ -139,7 +144,7 @@ CONFIG;
139144
openssl_x509_export($this->lastCert, $certText);
140145

141146
$keyText = '';
142-
openssl_pkey_export($this->lastKey, $keyText);
147+
openssl_pkey_export($this->lastKey, $keyText, null, $config);
143148

144149
file_put_contents($file, $certText . PHP_EOL . $keyText);
145150
} finally {

0 commit comments

Comments
 (0)