36 'capture_peer_cert' =>
true,
37 'allow_self_signed' =>
true 42 if ($srcMetadata->
hasValue(
'saml.SOAPClient.certificate')) {
43 $cert = $srcMetadata->
getValue(
'saml.SOAPClient.certificate');
44 if ($cert !==
false) {
46 $srcMetadata->
getString(
'saml.SOAPClient.certificate')
48 if ($srcMetadata->
hasValue(
'saml.SOAPClient.privatekey_pass')) {
49 $ctxOpts[
'ssl'][
'passphrase'] = $srcMetadata->
getString(
'saml.SOAPClient.privatekey_pass');
56 if ($privateKey !== null && $publicKey !== null && isset($publicKey[
'PEM'])) {
57 $keyCertData = $privateKey[
'PEM'] . $publicKey[
'PEM'];
59 if (!file_exists($file)) {
62 $ctxOpts[
'ssl'][
'local_cert'] = $file;
63 if (isset($privateKey[
'password'])) {
64 $ctxOpts[
'ssl'][
'passphrase'] = $privateKey[
'password'];
70 if ($dstMetadata !== null) {
71 $peerPublicKeys = $dstMetadata->
getPublicKeys(
'signing',
true);
73 foreach ($peerPublicKeys as
$key) {
74 if ($key[
'type'] !==
'X509Certificate') {
77 $certData .=
"-----BEGIN CERTIFICATE-----\n" .
78 chunk_split($key[
'X509Certificate'], 64) .
79 "-----END CERTIFICATE-----\n";
82 if (!file_exists($peerCertFile)) {
86 $ctxOpts[
'ssl'][
'verify_peer'] =
true;
87 $ctxOpts[
'ssl'][
'verify_depth'] = 1;
88 $ctxOpts[
'ssl'][
'cafile'] = $peerCertFile;
91 if ($srcMetadata->
hasValue(
'saml.SOAPClient.stream_context.ssl.peer_name')) {
92 $ctxOpts[
'ssl'][
'peer_name'] = $srcMetadata->
getString(
'saml.SOAPClient.stream_context.ssl.peer_name');
95 $context = stream_context_create($ctxOpts);
97 throw new \Exception(
'Unable to create SSL stream context');
102 'location' => $msg->getDestination(),
106 if ($srcMetadata->
hasValue(
'saml.SOAPClient.proxyhost')) {
107 $options[
'proxy_host'] = $srcMetadata->
getValue(
'saml.SOAPClient.proxyhost');
110 if ($srcMetadata->
hasValue(
'saml.SOAPClient.proxyport')) {
111 $options[
'proxy_port'] = $srcMetadata->
getValue(
'saml.SOAPClient.proxyport');
122 $action =
'http://www.oasis-open.org/committees/security';
128 if ($soapresponsexml === null || $soapresponsexml ===
"") {
129 throw new \Exception(
'Empty SOAP response, check peer certificate.');
138 throw new \Exception(
'Not a SOAP response.', 0, $e);
142 if (isset($soapfault)) {
143 throw new \Exception($soapfault);
146 $samlresponse =
Utils::xpQuery($dom->firstChild,
'/soap-env:Envelope/soap-env:Body/*[1]');
150 self::addSSLValidator($samlresponse,
$context);
154 return $samlresponse;
static resolveCert($path)
foreach($paths as $path) $request
hasValue($name)
Check whether a key in the configuration exists or not.
getValue($name, $default=null)
Retrieve a configuration option set in config.php.
static writeFile($filename, $data, $mode=0600)
static loadPublicKey(SimpleSAML_Configuration $metadata, $required=false, $prefix='')
static xpQuery(\DOMNode $node, $query)
Do an XPath query on an XML node.
catch(Exception $e) if(!($request instanceof \SAML2\ArtifactResolve)) $issuer
getPublicKeys($use=null, $required=false, $prefix='')
Get public key from metadata.
getString($name, $default=self::REQUIRED_OPTION)
This function retrieves a string configuration option.
static loadPrivateKey(SimpleSAML_Configuration $metadata, $required=false, $prefix='')
static fromXML(\DOMElement $xml)
Convert an XML element into a message.
getSOAPFault($soapMessage)