@@ -6,34 +6,36 @@ if (!extension_loaded("openssl")) die("skip openssl not loaded");
6
6
?>
7
7
--FILE--
8
8
<?php
9
- $ ssl_configargs = [
10
- "digest_alg " => "sha1 " ,
11
- "encrypt_key " => false ,
12
- "basicConstraints " => "CA:true " ,
13
- "keyUsage " => "cRLSign, keyCertSign " ,
14
- "nsCertType " => "sslCA, emailCA " ,
15
- "config " => __DIR__ . "/openssl.cnf " ,
16
- ];
9
+ $ cert = "file:// " . __DIR__ . "/cert.crt " ;
10
+ $ priv = "file:// " . __DIR__ . "/private_rsa_1024.key " ;
11
+ $ config = __DIR__ . DIRECTORY_SEPARATOR . 'openssl.cnf ' ;
12
+
17
13
$ dn = [
18
14
"countryName " => "GB " ,
19
15
"stateOrProvinceName " => "Berkshire " ,
20
16
"localityName " => "Newbury " ,
21
17
"organizationName " => "My Company Ltd " ,
22
18
"commonName " => "Demo Cert " ,
23
19
];
24
- $ numberofdays = '365 ' ;
20
+
21
+ $ args = array (
22
+ "digest_alg " => "sha256 " ,
23
+ "private_key_bits " => 2048 ,
24
+ "private_key_type " => OPENSSL_KEYTYPE_RSA ,
25
+ "encrypt_key " => true ,
26
+ "config " => $ config
27
+ );
25
28
26
29
mkdir (__DIR__ . "/bug50293 " );
27
30
chdir (__DIR__ . "/bug50293 " );
28
31
29
- $ privkey = openssl_pkey_new ( $ ssl_configargs );
30
- $ csr = openssl_csr_new ($ dn , $ privkey , $ ssl_configargs );
31
- $ sscert = openssl_csr_sign ($ csr , null , $ privkey , $ numberofdays );
32
- openssl_csr_export ($ csr , $ csrout );
32
+ $ privkey = openssl_pkey_get_private ( ' file:// ' . __DIR__ . ' /private_ec.key ' );
33
+ $ csr = openssl_csr_new ($ dn , $ privkey , $ args );
34
+ $ sscert = openssl_csr_sign ($ csr , null , $ privkey , 365 , $ args );
35
+ openssl_csr_export ($ csr , $ csrout );;
33
36
openssl_x509_export ($ sscert , $ certout );
34
37
openssl_x509_export_to_file ($ sscert , "bug50293.crt " , false );
35
- openssl_pkey_export ($ privkey , $ pkeyout );
36
- openssl_pkey_export_to_file ($ privkey , "bug50293.pem " );
38
+ openssl_pkey_export_to_file ($ privkey , "bug50293.pem " , null , $ args );
37
39
38
40
var_dump (
39
41
file_exists ("bug50293.crt " ),
0 commit comments