What are best practices for handling SSL certificates in PHP SOAP requests?

When making SOAP requests in PHP that require SSL certificates, it is important to properly handle and verify the certificates to ensure secure communication. One best practice is to set the location of the SSL certificate file and the passphrase if needed. Additionally, it is recommended to verify the SSL certificate to ensure the validity of the server's certificate.

$options = array(
    'local_cert' => '/path/to/client.pem',
    'passphrase' => 'password',
    'stream_context' => stream_context_create(array(
        'ssl' => array(
            'verify_peer' => true,
            'verify_peer_name' => true,
            'allow_self_signed' => false
        )
    ))
);

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