How to add certificate to drupal_http_request()? I am currently setting up a payment method in my Drupal 7 site and following the API documentation for the service I could use this cURL command for testing purposes:

$ curl -s -S -i --cert
./Swish_Merchant_TestCertificate_1231181189.p12:swish --cert-type p12 --
cacert ./Swish_TLS_RootCA.pem --tlsv1.1 --header "Content-Type:
application/json"
https://mss.cpc.getswish.net/swish-cpcapi/api/v1/paymentrequests --data
'{ "payeePaymentReference" : "0123456789", "callbackUrl" :
"https://myfakehost.se/swishcallback.cfm", "payerAlias" : "4671234768",
"payeeAlias" : "1231181189", "amount" : "100", "currency" : "SEK",
"message" : "Kingston USB Flash Drive 8 GB" }'


But since I am developing this function in Drupal 7 I want to use drupal_http_request instead. But I am confused about how to include the certificates used in the cURL command. Anyone?

EDITED:
After the suggestion below I added a context parameter. I still get "connection refused by destination". Is there anything more I should do? This is how my function looks so far:

function create_payment_request(){
  // Send payment request to Swish API
  $headers =  array('Content-Type'=&gt;'application/JSON' );
  $url = "https://mss.cpc.getswish.net/swish-cpcapi/api/v1/paymentrequests";

  $context = stream_context_create([ 'ssl' =&gt; [
  'local_cert'        =&gt; '/mypathtocertificates/TestCertificate_123456789.pem',
  'passphrase'        =&gt; 'pass' ]]);

  $json = '{
  "payeePaymentReference": "0123456789",
  "callbackUrl: "/swish_callback",
  "payerAlias": "4671234768",
  "payeeAlias: "1231181189",
  "amount": "100",
  "currency": "SEK",
  "message": "testo 925"
}
';

  $options=array(
      'headers'=&gt;$headers,
      'context' =&gt; $context,
      'method'=&gt;'POST',
      'data'=&gt;$json,
    );

    $result=drupal_http_request($url, $options);
    dpm($result);
}
You need to supply a context parameter in the options for drupal_http_request. The value is a stream context created using the PHP function stream_context_create.

There are a lot of possible parameters so you may have to hunt through the parameter list to find the ones you want.