What are the best practices for handling certificates in PHP when using SOAP and HTTPS?

When using SOAP with HTTPS in PHP, it is important to handle certificates properly to ensure secure communication. One best practice is to verify the server's certificate to prevent man-in-the-middle attacks. This can be done by setting the "verify_peer" and "allow_self_signed" options to true in the SOAP client configuration.

$options = array(
    'stream_context' => stream_context_create(array(
        'ssl' => array(
            'verify_peer' => true,
            'allow_self_signed' => true
        )
    ))
);

$client = new SoapClient('https://example.com/wsdl', $options);