I wrote a small SIP client for a special purpose. Basically it connects to port 5060 using function fsockopen()
fsockopen()
$fp = fsockopen(\"10.0.0.1\", 5060,
I think some of your options are wrong for validating self signed certificates; the following should be enough to make it work:
$context = stream_context_create([ 'ssl' => [ 'verify_peer' => true, 'allow_self_signed' => true, 'local_cert' => 'cert.cer', ], ]);