Can';t使用SSL支持连接到RabbitMq-c
我正在尝试使用命令行在(SSL管道分支)中运行SSL示例“amqps_listenq”Can';t使用SSL支持连接到RabbitMq-c,c,ssl,openssl,rabbitmq,C,Ssl,Openssl,Rabbitmq,我正在尝试使用命令行在(SSL管道分支)中运行SSL示例“amqps_listenq” $./amqps_listenq [ServerIP] 5671 hello ./cacert.pem ./key.pem ./cert.pem 我犯了以下错误 opening SSL/TLS connection 当我尝试调试代码时,它在main中的以下块中失败 status = amqp_socket_open(socket, hostname, port); if (status) { d
$./amqps_listenq [ServerIP] 5671 hello ./cacert.pem ./key.pem ./cert.pem
我犯了以下错误
opening SSL/TLS connection
当我尝试调试代码时,它在main中的以下块中失败
status = amqp_socket_open(socket, hostname, port);
if (status) {
die("opening SSL/TLS connection");
}
当我调试到“amqp_socket_open”方法时,我发现它在amqp_openssl.c中的以下块中失败
if (self->verify) {
int status = amqp_ssl_socket_verify(self, host);
if (status) {
return -1;
}
}
我跟踪了amqp_ssl_socket_verify中的错误,发现我在以下块中失败
#ifdef _MSC_VER
#define strcasecmp _stricmp
#endif
if (strcasecmp(host, (char *)utf8_value)) {
goto error; //<-- it fails here
}
#ifdef _MSC_VER
#undef strcasecmp
#endif
exit:
OPENSSL_free(utf8_value);
return status;
error:
status = -1;
goto exit;
我一直在调试librabbitmq,我看到了完全相同的行为。utf8_值变量包含“amqp”,而主机变量包含amqp服务器主机名 我有一个解决办法:
- if (strcasecmp(host, (char *)utf8_value)) {
- goto error;
+
+ if(strcasecmp((char *)utf8_value, "amqp")) {
+ if (strcasecmp(host, (char *)utf8_value) ) {
+ goto error;
+ }
}
我在这里进行了分叉和修补:问题在于证书,请在证书详细信息中验证域是否匹配
- if (strcasecmp(host, (char *)utf8_value)) {
- goto error;
+
+ if(strcasecmp((char *)utf8_value, "amqp")) {
+ if (strcasecmp(host, (char *)utf8_value) ) {
+ goto error;
+ }
}