File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -938,8 +938,22 @@ static int php_openssl_set_local_cert(SSL_CTX *ctx, php_stream *stream) /* {{{ *
938
938
if (certfile ) {
939
939
char resolved_path_buff [MAXPATHLEN ];
940
940
const char * private_key = NULL ;
941
-
942
- if (VCWD_REALPATH (certfile , resolved_path_buff )) {
941
+ X509 * cert = NULL ;
942
+
943
+ /* val is certfile */
944
+ if (GET_VER_OPT ("local_cert" )) /* fill val with local_cert if any */
945
+ cert = php_openssl_x509_from_str (Z_STR_P (val ));
946
+ if (cert ) {
947
+ if (SSL_CTX_use_certificate (ctx , cert ) != 1 ) {
948
+ X509_free (cert );
949
+ php_error_docref (NULL , E_WARNING ,
950
+ "Invalid local cert `%s'; Check your device" ,
951
+ certfile );
952
+ return FAILURE ;
953
+ }
954
+ }
955
+ if (cert || VCWD_REALPATH (certfile , resolved_path_buff )) {
956
+ if (!cert ) {
943
957
/* a certificate to use for authentication */
944
958
if (SSL_CTX_use_certificate_chain_file (ctx , resolved_path_buff ) != 1 ) {
945
959
php_error_docref (NULL , E_WARNING ,
@@ -948,6 +962,7 @@ static int php_openssl_set_local_cert(SSL_CTX *ctx, php_stream *stream) /* {{{ *
948
962
certfile );
949
963
return FAILURE ;
950
964
}
965
+ } // TODO indent, WIP during code reviews
951
966
GET_VER_OPT_STRING ("local_pk" , private_key );
952
967
if (private_key ) {
953
968
char resolved_path_buff_pk [MAXPATHLEN ];
You can’t perform that action at this time.
0 commit comments