@@ -85,8 +85,8 @@ class CertificateGenerator
85
85
openssl_x509_export_to_file ($ this ->ca , $ file );
86
86
}
87
87
88
- public function saveNewCertAsFileWithKey (
89
- $ commonNameForCert , $ file , $ keyLength = null , $ subjectAltName = null
88
+ public function saveNewCertAndKey (
89
+ $ commonNameForCert , $ certFile , $ keyFile , $ keyLength = null , $ subjectAltName = null
90
90
) {
91
91
$ dn = [
92
92
'countryName ' => 'BY ' ,
@@ -117,7 +117,7 @@ $subjectAltNameConfig
117
117
basicConstraints = CA:FALSE
118
118
$ subjectAltNameConfig
119
119
CONFIG ;
120
- $ configFile = $ file . '.cnf ' ;
120
+ $ configFile = $ certFile . '.cnf ' ;
121
121
file_put_contents ($ configFile , $ configCode );
122
122
123
123
try {
@@ -146,12 +146,24 @@ CONFIG;
146
146
$ keyText = '' ;
147
147
openssl_pkey_export ($ this ->lastKey , $ keyText , null , $ config );
148
148
149
- file_put_contents ($ file , $ certText . PHP_EOL . $ keyText );
149
+ if ($ certFile === $ keyFile ) {
150
+ file_put_contents ($ certFile , $ certText . PHP_EOL . $ keyText );
151
+ } else {
152
+ file_put_contents ($ certFile , $ certText );
153
+ file_put_contents ($ keyFile , $ keyText );
154
+ }
150
155
} finally {
151
156
unlink ($ configFile );
152
157
}
153
158
}
154
159
160
+
161
+ public function saveNewCertAsFileWithKey (
162
+ $ commonNameForCert , $ file , $ keyLength = null , $ subjectAltName = null
163
+ ) {
164
+ $ this ->saveNewCertAndKey ($ commonNameForCert , $ file , $ file , $ keyLength , $ subjectAltName );
165
+ }
166
+
155
167
public function getCertDigest ($ algo )
156
168
{
157
169
return openssl_x509_fingerprint ($ this ->lastCert , $ algo );
0 commit comments