# SSLSocket-C **Repository Path**: fmldd/sslsocket-c ## Basic Information - **Project Name**: SSLSocket-C - **Description**: VS2010 + OpenSSL 实现SSL双向认证并,通过套接字通讯; - **Primary Language**: C/C++ - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 3 - **Created**: 2021-01-19 - **Last Updated**: 2023-04-25 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # SSLSocket-C #### 介绍 VS2010 + OpenSSL 实现SSL双向认证并通过套接字通讯; #### 证书生成 1.生成自签名根证书 ``` :: 生成根证书私钥(pem文件) openssl genrsa -out root.key 2048 :: 生成根证书签发申请文件(csr文件) openssl req -new -key root.key -out root.csr -subj "/CN=localhost/C=CN/ST=rootprovince/L=rootcity/O=rootorganization/OU=rootgroup" :: 自签发根证书(cer文件) openssl x509 -req -days 365 -extensions v3_ca -signkey root.key -in root.csr -out root.crt ``` 2.通过CA证书签发服务端证书 ``` :: 生成服务端私钥 openssl genrsa -out server.key 2048 :: 生成证书请求文件 openssl req -new -key server.key -out server.csr -subj "/CN=localhost/C=CN/ST=serverprovince/L=servercity/O=serverorganization/OU=servergroup" :: 使用根证书签发服务端证书 openssl x509 -req -days 365 -extensions v3_req -CA root.crt -CAkey root.key -CAserial root.srl -CAcreateserial -in server.csr -out server.crt :: 使用CA证书验证服务端证书 openssl verify -CAfile root.crt server.crt ``` 3.通过CA证书签发客户端证书 ``` :: 生成客户端私钥 openssl genrsa -out client.key 2048 :: 生成证书请求文件 openssl req -new -key client.key -out client.csr -subj "/CN=localhost/C=CN/ST=clientprovince/L=clientcity/O=clientorganization/OU=clientgroup" :: 使用根证书签发客户端证书 openssl x509 -req -days 365 -extensions v3_req -CA root.crt -CAkey root.key -CAserial root.srl -CAcreateserial -in client.csr -out client.crt :: 使用CA证书验证客户端证书 openssl verify -CAfile root.crt client.crt ``` #### 文档