`
nanjingjiangbiao_T
  • 浏览: 2658487 次
  • 来自: 深圳
文章分类
社区版块
存档分类
最新评论

SSL_shutdown返回值的研究(2)

 
阅读更多

1.Analyze:
According to the conclusion(1)of return value of SSL_shutdown:
a.Return code 0 indicates that the application issued the SSL_shutdown function first. Continue issuing the SSL_shutdown function until you receive return code 1, which indicates the remote application has also shut down.

    b.SSL_shutdown() supports both uni- and bidirectional shutdown by its 2
step behaviour. c.When the application is the first party to send the "close notify" alert, SSL_shutdown() will only send the alert and the set the SSL_SENT_SHUTDOWN flag (so that the session is considered good and willbe kept in cache). SSL_shutdown() will then return with 0. If a unidi-rectional shutdown is enough (the underlying connection shall be closed anyway), this first call to SSL_shutdown() is sufficient. In order to complete the bidirectional shutdown handshake, SSL_shutdown() must be called again. The second call will make SSL_shutdown() wait for the peer's "close notify" shutdown alert. On success, the second call to SSL_shutdown() will return with 1.
2.sample:
ret = SSL_shutdown(ssl);/*First call*/
printf("line=%d,ret=%d\n",__LINE__,ret);
if(ret != 1)
SSL_shutdown(ssl);/*Call again*/
done:
/*end socket */
close(sockfd);
SSL_free(ssl);
SSL_CTX_free(ctx);
ERR_free_strings();
分享到:
评论

相关推荐

    ssl相关应用程序,实现身份认证功能、数据传输加密功能源代码.doc

    `ssl_free`函数用于释放分配的资源,包括调用`SSL_shutdown`关闭SSL连接,如果`shutdown`标志被设置,还会调用`SSL_free`释放SSL句柄,并清理`BIO`结构。 `ssl_read`函数执行SSL的读操作。它首先检查是否已完成SSL...

    OpenSSL编程实例复习过程.pdf

    11. SSL/TLS 协议关闭:使用 `SSL_shutdown` 函数关闭 SSL/TLS 协议,並释放资源。 在 OpenSSL 编程实例复习过程中,我们需要了解这些重要知识点,以便正确地使用 OpenSSL 库实现加密和解密功能。

    openssl-example-master, OpenSSL异步连接源码

    2. **创建 SSL 上下文 (Context)**:`SSL_CTX* SSL_CTX_new(SSL_METHOD*)` 函数用于创建 SSL 上下文,它是所有 SSL 连接的基础。异步连接通常需要选择支持非阻塞模式的 SSL 方法,例如 `SSLv23_method()`。 3. **...

    OpenSSLSocketImpl.rar_Windows编程_Unix_Linux_

    在会话结束时,`OpenSSLSocketImpl`需要关闭SSL连接,这涉及到调用`SSL_shutdown()`和`SSL_free()`。同时,底层的socket也需要关闭,防止资源泄露。 为了保证安全性,`OpenSSLSocketImpl`还需要处理各种异常情况,...

    nopoll实现websocket

    4. **错误处理**:在使用过程中,应定期检查`nopoll_conn_is_ok`函数的返回值,判断连接是否仍然有效。如果遇到错误,可以通过`nopoll_conn_get_error`获取错误信息。 5. **关闭连接**:完成通信后,可以调用`...

    Windows Sockets 完全进阶

    5. **SSL/TLS安全通信**:对于需要加密通信的应用,可以集成OpenSSL库,利用`SSL_CTX`和`SSL`对象实现安全套接字层(SSL)或传输层安全(TLS)。 通过深入学习和实践以上知识点,你将能够熟练地运用Winsock API开发...

    Windows_Server_Socket_Program_C++_tcp_

    当通信结束后,使用`shutdown`函数停止发送或接收数据,然后调用`close`函数关闭套接字。注意,关闭套接字并不立即断开连接,而是发送一个FIN标志,等待对方确认后才能完全断开。 十、示例代码 在“Socket_...

    PHP通过ice调用python程序.pdf

    此外,代码还检查了是否启用SSL以及调用模式等。 总的来说,通过Ice,我们可以轻松地在PHP和Python之间建立通信,实现服务调用。这种方式特别适用于PHP无法直接处理的复杂任务,或者需要利用Python的强大功能,如...

    PHP通过ice调用python程序借鉴.pdf

    2. **Slice定义**:Slice是一种接口定义语言,类似于IDL(Interface Definition Language),用于描述服务接口和数据类型。在`Hello.ice`文件中定义了名为`Demo.Hello`的接口,包含了几个方法,如`sayHello`、`...

    流式套接字实现简单的客户端服务端通信过程

    - TCP本身不提供加密,但可以与SSL/TLS结合使用,形成安全套接字层(Secure Sockets Layer,SSL)或传输层安全(Transport Layer Security,TLS),以保护数据传输的安全性。 通过以上步骤,我们可以理解并实现...

Global site tag (gtag.js) - Google Analytics