Reputation: 347
Based on https://www.bankid.com/assets/bankid/rp/bankid-relying-party-guidelines-v2.13.pdf
I have working curl
command:
curl https://appapi.test.bankid.com/rp/v4?wsdl -E --cacert /path/to/BankID_SSL_Root_Certification_Authority_TEST.pem --cert /path/to/ServerCertificate.cer --key /path/to/PrivateKey.key
ServerCertificate.cer and PrivateKey.key were extracted from PFX certificate (https://www.bankid.com/assets/bankid/rp/FPTestcert2_20150818_102329.pfx) with openssl
command.
But I can't make it work with PHP SoapClient:
SOAP-ERROR: Parsing WSDL: Couldn't load from 'https://appapi.test.bankid.com/rp/v4?wsdl' : failed to load external entity "https://appapi.test.bankid.com/rp/v4?wsdl"
I will appreciate any help here.
Upvotes: 2
Views: 2077
Reputation: 11
Just for future people finding themselves with the same BankID problem, Dmitry gave a very good tutorial on how to get the correct certificate, but the code that worked for me required a few more parameters:
try {
$client = new SoapClient('https://appapi2.test.bankid.com/rp/v4?wsdl',
["local_cert" => "certname.pem",
"stream_context" => [
"ssl" => [
"verify_peer" => false,
"verify_peer_name" => false,
"allow_self_signed" => true
]
]
]);
} catch (Exception $e) {
return json_encode( array( "result" => false, "reason" => $e->getMessage() ) );
}
Upvotes: 1
Reputation: 347
Thank you guys for your answers.
The solution:
openssl pkcs12 -in FPTestcert2_20150818_102329.pfx -nocerts -out key.pem -nodes
openssl pkcs12 -in FPTestcert2_20150818_102329.pfx -nokeys -out cert.pem
openssl rsa -in key.pem -out server.key
-----BEGIN RSA PRIVATE KEY-----
...
-----END RSA PRIVATE KEY-----
server.key
and-----BEGIN CERTIFICATE-----
...
-----END CERTIFICATE-----
cert.pem
and put them into new certname.pem
file.Then:
try {
$this->client = new SoapClient( $this->wsdl, array( "local_cert" => "/path_to_cert/certname.pem" ) );
} catch (Exception $e) {
return json_encode( array( "result" => false, "reason" => $e->getMessage() ) );
}
Upvotes: 2