所以我在bluemix上有一个安全的网关。 安全网关连接到我本地的LDAP服务。 在安全网关中,我配置了一个相互TLS。
现在,我正在使用React \ socket-client进行连接,并且连接成功。我刚刚失去了如何查询LDAP中的数据。始终无法连接到LDAP服务器。
$loop = React\EventLoop\Factory::create();
$tcpConnector = new React\SocketClient\TcpConnector($loop);
$dnsResolverFactory = new React\Dns\Resolver\Factory();
$dns = $dnsResolverFactory->createCached('8.8.8.8', $loop);
$dnsConnector = new React\SocketClient\DnsConnector($tcpConnector, $dns);
$secureConnector = new React\SocketClient\SecureConnector($dnsConnector, $loop, array(
'verify_peer' => true,
'verify_peer_name' => true,
'allow_self_signed' => true,
'cafile' => <CACERT>,
'local_pk' => <PK_CERT>,
'local_cert' => <LOCALCERT>
));
$secureConnector->create(<Secure Gateway Link>)->then(function(React\Stream\Stream $stream)
{
//I'M CONNECTED HERE
//Secure gateway status is establishing connection and not closing
$ldap_server = "ldap://0.0.0.0";
$basedn = "<xxx>";
$auth_user = "<xxx>";
$auth_pass = "<xxx>";
if (!($connect = @ldap_connect($ldap_server)))
{
throw new Exception("Cannot connect to LDAP");
} else
{
try
{
//In order to avoid unable bind to server
ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3);
$bind = ldap_bind($connect, $auth_user, $auth_pass);
if (!$bind)
{
if (ldap_get_option($connect, LDAP_OPT_DIAGNOSTIC_MESSAGE, $extended_error))
{
throw new Exception("Error Binding to LDAP: $extended_error");;
} else
{
throw new Exception("Error Binding to LDAP: No additional information is available.");
}
} else
{
//connected to LDAP and do search
//never goes here
}
} catch (Exception $exc)
{
$exc->getMessage();
$stream->end();
}
}
}, function($err)
{
echo $err . '<br>';
die();
});
$loop->run();
我在https://developer.ibm.com/bluemix/2015/04/17/securing-destinations-tls-bluemix-secure-gateway/上翻译nodejs代码 这个代码.... 如果必须,我可以使用另一个数据包,我只是不知道该使用什么。 请帮帮我..
提前致谢