Has anyone used this package to interact with the Medical Claims Electronic Data Transfer (MCEDT) via Electronic Business Services (EBS);
http://www.health.gov.on.ca/en/pro/publications/ohip/docs/techspec_mcedt_ebs.pdf.
I have been trying to figure out how to get all this working, and I created a self-signed certificate in wamp via:
openssl genrsa -out server.key 4096
openssl req -new -x509 -nodes -sha1 -days 365 -key server.key -out server.crt
I then modified one of the examples that came with this package to create the request the documentation is looking for:
class mySoap extends SoapClient {
private $_username;
private $_password;
private $_digest;
function addUserToken($username, $password, $digest = false) {
$this->_username = $username;
$this->_password = $password;
$this->_digest = $digest;
}
function __doRequest($request, $location, $saction, $version, $one_way = null) {
$doc = new DOMDocument('1.0');
$doc->loadXML($request);
$doc->createAttributeNS('http://msa.ebs.health.ontario.ca/', 'msa:MSA');
$objWSSE = new WSSESoap($doc);
/* Sign all headers to include signing the WS-Addressing headers */
$objWSSE->signAllHeaders = TRUE;
/* add Timestamp with no expiration timestamp */
$objWSSE->addTimestamp();
$objWSSE->addUserToken($this->_username, $this->_password, $this->_digest);
/* create new XMLSec Key using AES256_CBC and type is private key */
$objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array('type' => 'private'));
/* load the private key from file - last arg is bool if key in file (TRUE) or is string (FALSE) */
$objKey->loadKey(PRIVATE_KEY, true);
/* Sign the message - also signs appropiate WS-Security items */
$options = array("insertBefore" => FALSE);
$objWSSE->signSoapDoc($objKey, $options);
/* Add certificate (BinarySecurityToken) to the message */
$token = $objWSSE->addBinaryToken(file_get_contents(CERT_FILE));
/* Attach pointer to Signature */
$objWSSE->attachTokentoSig($token);
$xml = $objWSSE->saveXML();
$retVal = parent::__doRequest($xml, $location, $saction, $version, $one_way);
$doc = new DOMDocument('1.0');
$doc->loadXML($retVal);
$options = array("keys" => array("private" => array("key" => PRIVATE_KEY, "isFile" => TRUE, "isCert" => FALSE)));
$objWSSE->decryptSoapDoc($doc, $options);
return $doc->saveXML();
}
}
But the service replies with a fault: Authorization failed; contact your technical support or software vendor.
I contact the Ministry of Health and they said it is a problem with the certificate.
The documentation seems to suggest I send my Public Key in the request so they can encrypt the response. I was also provided a 3 .pem files, along with the WSDL I reference, one of which I use as the CERT_FILE. I tried changing some code so I use the Public Key I generated:
$objKey = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array('type' => 'public'));
$objKey->loadKey(PUBLIC_KEY, true, true);
...but I get the following errors:
Warning: openssl_sign(): supplied key param is a public key in
...\wse-php-master\xmlseclibs.php on line
453
Warning: openssl_sign(): supplied key param cannot be coerced into a private key in
...\wse-php-master\xmlseclibs.php on line
453** My question is has anyone implemented a solution for MCEDT EBS using this package, and if so what am I doing wrong in terms of the request signing/securing and/or creating the cert?
Thanks!!