简体   繁体   English

SSL_accept()不起作用

[英]SSL_accept() Not Working

I have researched for a while now, and didn't see my exact same problem anywhere. 我已经研究了一段时间,在任何地方都没有看到我完全相同的问题。 I'm just having a specific, quite simple problem: whenever my echo_server tries to run SSL_accept() function, it won't block the server waiting for a client to connect, function will just return 0, and if I go into SSL_get_error() , it will give me SSL_ERROR_SYSCALL , so I'm guessing the problem is, quoting from the manual, "an EOF was observed that violates the protocol." 我只是遇到一个特定的,非常简单的问题:每当我的echo_server尝试运行SSL_accept()函数时,它都不会阻止服务器等待客户端连接,该函数只会返回0,如果我进入SSL_get_error() ,它会给我SSL_ERROR_SYSCALL ,所以我猜是问题出在手册中,“观察到一个EOF违反了协议”。

Truth is I have no idea what does that mean, and it's getting really frustrating because I think I'm missing something very simple, but I don't know what. 真相是我不知道这意味着什么,而且它真的令人沮丧,因为我认为我错过了一些非常简单的东西,但我不知道这是什么。

Here's the code for my accept function (SSL_ctx previously initialized and socket opened): 这是我的accept函数的代码(之前已初始化SSL_ctx并打开了套接字):

SSL * sslconnection;

if((sslconnection = SSL_new(ctx)) == NULL){
    return NULL;
}

if(SSL_set_fd(sslconnection, socketd) != 1){
    return NULL;
}

if(SSL_accept(sslconnection) != 1){
    return NULL;
}

return sslconnection;

Also, I've tried to check my certificates with "openssl verify -verbose -purpose sslserver -CAfile 'CACertificate' 'ServerCertificate'", but it would say my Server Certificate is ok. 另外,我尝试用“ openssl verify -verbose -purpose sslserver -CAfile'CACertificate''ServerCertificate'”检查我的证书,但它表示我的服务器证书还可以。

Any help is welcome, thanks in advance. 欢迎任何帮助,在此先感谢。 Hope it's something really stupid and I'm just so obfuscated I can't see it. 希望这真的很愚蠢,我太困惑了,我看不到它。

whenever my echo_server tries to run SSL_accept() function, it won't block the server waiting for a client to connect 每当我的echo_server尝试运行SSL_accept()函数时,它都不会阻止服务器等待客户端连接

SSL_accept does not call accept for you. SSL_accept不会为您调用accept It expects that accept has already been called. 它期望accept已经被调用。

The correct sequence of calls is: 正确的呼叫顺序是:

  1. socket
  2. bind
  3. listen
  4. accept
  5. SSL_new
  6. SSL_set_fd
  7. SSL_accept

Download openssl sources from https://www.openssl.org/source/ and see demos/ssl/serv.cpp. https://www.openssl.org/source/下载openssl来源,并查看demos / ssl / serv.cpp。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM