基于openssl的golang ahead源码分析与https协议实现
发布时间
阅读量:
阅读量
HTTP协议存在安全隐患,其数据传输为明文形式,因此需借助OpenSSL库实现安全的HTTPS协议。当启用HTTPS协议后,服务器与浏览器两端将自动对通信内容进行加密与解密操作,从而确保信息传输的安全性。在goahead-openssl.c文件中,通过集成OpenSSL库的方式封装了具备安全功能的读写函数。
一、SSL读函数实现与分析
/*
Read from a connection. Return the number of bytes read if successful. This may be less than the requested "len" and
may be zero. Return -1 for errors or EOF. Distinguish between error and EOF via socketEof().
*/
static ssize websRead(Webs *wp, char *buf, ssize len)
{
assert(wp);
assert(buf);
assert(len > 0);
#if ME_COM_SSL
if (wp->flags & WEBS_SECURE) {//https
全部评论 (0)
还没有任何评论哟~
