Does PHP SoapClient support HTTPS connections

后端 未结 4 1477
庸人自扰
庸人自扰 2020-12-18 12:43

I\'m using XAMPP on Windows and try to work with PHP soap extension SoapClient. I\'m trying to load a WSDL file hosted in HTTPS site using the following code



        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-18 13:16

    To workaround this error you could deactivate the SSL certificate validation. But keep in mind, that this should only be done for test cases, because this makes your connection insecure!

    You can pass a stream context when instantiating the SoapClient like this:

     stream_context_create([
            'ssl' => [
                'verify_peer' => false,
                'verify_peer_name' => false,
            ],
        ]),
    ]);
    

    If you have a valid certificate but it is selfsigned, there is another solution (more secure):

     stream_context_create([
            'ssl' => [
                'allow_self_signed' => true,
            ],
        ]),
    ]);
    

提交回复
热议问题