SMTPS:OpenSSL-SSL例程:SSL23_GET_SERVER_HELLO:未知协议s23_clnt.c:787: [英] SMTPS: OpenSSL - SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol s23_clnt.c:787:

查看:492
本文介绍了SMTPS:OpenSSL-SSL例程:SSL23_GET_SERVER_HELLO:未知协议s23_clnt.c:787:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用OpenSSL来加密某些硬件发送的电子邮件.但是,每当我尝试调用SSL_connect()时,我都会得到: SSL例程:SSL23_GET_SERVER_HELLO:未知协议

I'm using OpenSSL in order to encrypt some emails, that a piece of hardware sends. But, whenever I try to call SSL_connect(), I get : SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

发送"EHLO"和"STARTTLS"后,我调用以下函数:

After sending "EHLO" and "STARTTLS" I call the following function:

SSL_CTX *ctx = NULL;
SSL *ssl = NULL;

    void CreateTLSSession(int sockfd)
    {
        printf("///////////////creating TLS Session/////////////////////\n");
        SSL_library_init();
        SSL_load_error_strings();
        OpenSSL_add_all_algorithms();
        ctx = SSL_CTX_new(SSLv23_client_method());
        if (ctx == NULL)
        {
            printf("failed to initialize context\n");
            return;
        }
        SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2);
        ssl = SSL_new(ctx);
        if (!SSL_set_fd(ssl, sockfd))
        {
            printf("failed to bind to socket fd\n");
            return;
        }
        if (SSL_connect(ssl) < 1)
        {
            ERR_print_errors_fp(stdout);
            fflush(stdout);
            printf("SSL_connect failed\n");
            return;
        }
    }

我尝试连接到:

  • smtp.live.com:587-> SSL例程:SSL23_GET_SERVER_HELLO:未知 协议s23_clnt.c:787:
  • smtp.live.com:25-> SSL例程:SSL23_GET_SERVER_HELLO:未知协议s23_clnt.c:787:
  • smtp.gmail.com:587-> SSL例程:SSL23_GET_SERVER_HELLO:未知 协议s23_clnt.c:787:
  • smtp.gmail.com:465->服务器完全没有响应!
  • smtp.gmail.com:25-> SSL例程:SSL23_GET_SERVER_HELLO:未知
    协议s23_clnt.c:787:
  • smtp.live.com : 587 --> SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol s23_clnt.c:787:
  • smtp.live.com : 25 --> SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol s23_clnt.c:787:
  • smtp.gmail.com : 587 --> SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol s23_clnt.c:787:
  • smtp.gmail.com : 465 --> no response from server at all!
  • smtp.gmail.com : 25 --> SSL routines:SSL23_GET_SERVER_HELLO:unknown
    protocol s23_clnt.c:787:

我尝试了不同的端口,因为对此SO提出了一些类似的问题,因此这种错误通常与对SSL使用错误的端口有关.

I've tried different ports, since some similar questions on this SO suggested, that such error is usually related to using the wrong port for SSL.

我在这里想念东西吗?

更新:

所有其他方法(例如TLSv1_1_method(),SSLv3_method()...)导致SSL3_GET_RECORD:版本号错误

All other methods (i.e. TLSv1_1_method(), SSLv3_method() ...) lead to SSL3_GET_RECORD:wrong version number

更新:

我能够在Wireshark上观察到以下内容:

I was able to observe the following on wireshark:

"EHLO"

为您服务"

"STARTTLS"

"STARTTLS"

准备开始"

->现在我调用上面的函数

-->now I call the above function

无法读取的请求(已加密)

unreadable request (encrypted)

不可读的答复(已加密)

unreadable reply (encrypted)

->错误

推荐答案

所存储的基础对象是非阻塞的.通过使用select并等待TLS握手完成,此问题已解决.

The underlying socked was non-blocking. The problem was solved, by using select and waiting till the TLS handshake completes.

这篇关于SMTPS:OpenSSL-SSL例程:SSL23_GET_SERVER_HELLO:未知协议s23_clnt.c:787:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆