openssl s_server命令

使用openssl s_server 测试搭建https-server测试,选项如下:

usage: s_server [args ...]

 -accept arg   - port to accept on (default is 4433)
 -verify_hostname host - check peer certificate matches "host"
 -verify_email email - check peer certificate matches "email"
 -verify_ip ipaddr - check peer certificate matches "ipaddr"
 -context arg  - set session ID context
 -verify arg   - turn on peer certificate verification
 -Verify arg   - turn on peer certificate verification, must have a cert.
 -verify_return_error - return verification errors
 -cert arg     - certificate file to use
                 (default is server.pem)
 -serverinfo arg - PEM serverinfo file for certificate
 -auth               - send and receive RFC 5878 TLS auth extensions and supplemental data
 -auth_require_reneg - Do not send TLS auth extensions until renegotiation
 -no_resumption_on_reneg - set SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION flag
 -crl_check    - check the peer certificate has not been revoked by its CA.
                 The CRL(s) are appended to the certificate file
 -crl_check_all - check the peer certificate has not been revoked by its CA
                 or any other CRL in the CA chain. CRL(s) are appened to the
                 the certificate file.
 -certform arg - certificate format (PEM or DER) PEM default
 -key arg      - Private Key file to use, in cert file if
                 not specified (default is server.pem)
 -keyform arg  - key format (PEM, DER or ENGINE) PEM default
 -pass arg     - private key file pass phrase source
 -dcert arg    - second certificate file to use (usually for DSA)
 -dcertform x  - second certificate format (PEM or DER) PEM default
 -dkey arg     - second private key file to use (usually for DSA)
 -dkeyform arg - second key format (PEM, DER or ENGINE) PEM default
 -dpass arg    - second private key file pass phrase source
 -dhparam arg  - DH parameter file to use, in cert file if not specified
                 or a default set of parameters is used
 -named_curve arg  - Elliptic curve name to use for ephemeral ECDH keys.
                 Use "openssl ecparam -list_curves" for all names
                 (default is nistp256).
 -nbio         - Run with non-blocking IO
 -nbio_test    - test with the non-blocking test bio
 -crlf         - convert LF from terminal into CRLF
 -debug        - Print more output
 -msg          - Show protocol messages
 -state        - Print the SSL states
 -CApath arg   - PEM format directory of CA's
 -CAfile arg   - PEM format file of CA's
 -trusted_first - Use trusted CA's first when building the trust chain
 -no_alt_chains - only ever use the first certificate chain found
 -nocert       - Don't use any certificates (Anon-DH)
 -cipher arg   - play with 'openssl ciphers' to see what goes here
 -serverpref   - Use server's cipher preferences
 -quiet        - No server output
 -no_tmp_rsa   - Do not generate a tmp RSA key
 -krb5svc arg  - Kerberos service name
 -keytab arg   - Kerberos keytab filename
 -psk_hint arg - PSK identity hint to use
 -psk arg      - PSK in hex (without 0x)
 -ssl3         - Just talk SSLv3
 -tls1_2       - Just talk TLSv1.2
 -tls1_1       - Just talk TLSv1.1
 -tls1         - Just talk TLSv1
 -dtls1        - Just talk DTLSv1
 -dtls1_2      - Just talk DTLSv1.2
 -timeout      - Enable timeouts
 -mtu          - Set link layer MTU
 -chain        - Read a certificate chain
 -no_ssl2      - No-op, SSLv2 is always disabled
 -no_ssl3      - Just disable SSLv3
 -no_tls1      - Just disable TLSv1
 -no_tls1_1    - Just disable TLSv1.1
 -no_tls1_2    - Just disable TLSv1.2
 -no_dhe       - Disable ephemeral DH
 -no_ecdhe     - Disable ephemeral ECDH
 -bugs         - Turn on SSL bug compatibility
 -hack         - workaround for early Netscape code
 -www          - Respond to a 'GET /' with a status page
 -WWW          - Respond to a 'GET /<path> HTTP/1.0' with file ./<path>
 -HTTP         - Respond to a 'GET /<path> HTTP/1.0' with file ./<path>
                 with the assumption it contains a complete HTTP response.
 -engine id    - Initialise and use the specified engine
 -id_prefix arg - Generate SSL/TLS session IDs prefixed by 'arg'
 -rand file:file:...
 -servername host - servername for HostName TLS extension
 -servername_fatal - on mismatch send fatal alert (default warning alert)
 -cert2 arg    - certificate file to use for servername
                 (default is server2.pem)
 -key2 arg     - Private Key file to use for servername, in cert file if
                 not specified (default is server2.pem)
 -tlsextdebug  - hex dump of all TLS extensions received
 -no_ticket    - disable use of RFC4507bis session tickets
 -legacy_renegotiation - enable use of legacy renegotiation (dangerous)
 -sigalgs arg      - Signature algorithms to support (colon-separated list)
 -client_sigalgs arg  - Signature algorithms to support for client 
                        certificate authentication (colon-separated list)
 -nextprotoneg arg - set the advertised protocols for the NPN extension (comma-separated list)
 -use_srtp profiles - Offer SRTP key management with a colon-separated profile list
 -alpn arg  - set the advertised protocols for the ALPN extension (comma-separated list)
 -keymatexport label   - Export keying material using label
 -keymatexportlen len  - Export len bytes of keying material (default 20)
 -status           - respond to certificate status requests
 -status_verbose   - enable status request verbose printout
 -status_timeout n - status request responder timeout
 -status_url URL   - status request fallback URL

选项解释:

-accept arg -  port的默认监听端口4433

-key arg      -  私钥

-cert arg      -  签发的证书【用csr签发】


简单示例

说明: 采用根证书,自签证的证书;

--------------------------------------

1 单向认证

服务端:

openssl s_server -key server.key -cert server.crt

客户端:

[root@localhost ~]# openssl s_client -connect localhost:4433 -verify_return_error
CONNECTED(00000003)
depth=0 C = CN, ST = FJ, L = xiamen, O = yl, OU = yl1, CN = yl2
verify error:num=18:self signed certificate  //<--自签发
---
Certificate chain
 0 s:/C=CN/ST=FJ/L=xiamen/O=yl/OU=yl1/CN=yl2
   i:/C=CN/ST=FJ/L=xiamen/O=yl/OU=yl1/CN=yl2
---
Server certificate
-----BEGIN CERTIFICATE-----

2 双向认证

   服务端:

   -Verify 1 客户端必须发送一个证书

openssl s_server -key 1.key -cert 1.crt  -CAfile ../server.crt -Verify 1

   客户端:

openssl s_client -connect localhost:4433 -CAfile server.crt -cert 1/1.crt  -key 1/1.key  -showcerts
 openssl s_client 参数说明请 点击打开链接
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
第一章 基础知识 8<br>1.1 对称算法 8<br>1.2摘要算法 8<br>1.3 公钥算法 9<br>1.4 回调函数 11<br>第二章 openssl简介 13<br>2.1 openssl简介 13<br>2.2 openssl安装 13<br>2.2.1 linux下的安装 13<br>2.2.2 windows编译与安装 13<br>2.3 openssl源代码 14<br>2.4 openssl学习方法 16<br>第三章openssl堆栈 17<br>3.1 openssl堆栈 17<br>3.2 数据结构 17<br>3.3 源码 17<br>3.4 定义用户自己的堆栈函数 18<br>3.5 编程示例 19<br>第四章 openssl哈希表 21<br>4.1 哈希表 21<br>4.2 哈希表数据结构 21<br>4.3 函数说明 22<br>4.4 编程示例 24<br>第五章 openssl内存分配 27<br>5.1 openssl内存分配 27<br>5.2 内存数据结构 27<br>5.3 主要函数 28<br>5.4 编程示例 28<br>第六章 Openssl动态模块加载 31<br>6.1 动态库加载 31<br>6.2 DSO概述 31<br>6.3 数据结构 31<br>6.4 编程示例 32<br>第七章 openssl抽象IO 35<br>7.1 openssl抽象IO 35<br>7.2 数据结构 35<br>7.3 BIO 函数 36<br>7.4 编程示例 37<br>7.4.1 mem bio 37<br>7.4.2 file bio 37<br>7.4.3 socket bio 38<br>7.4.4 md BIO 40<br>7.4.5 cipher BIO 40<br>7.4.6 ssl BIO 41<br>7.4.7 其他示例 43<br>第八章 Openssl配置文件 44<br>8.1 概述 44<br>8.2 openssl配置文件读取 44<br>8.3 主要函数 44<br>8.4 编程示例 45<br>第九章 Openssl随机数 47<br>9.1 随机数 47<br>9.2 openssl随机数数据结构与源码 47<br>9.3 主要函数 48<br>9.4 编程示例 49<br>第十章 Openssl文本数据库 51<br>10.1 概述 51<br>10.2 数据结构 51<br>10.3 函数说明 52<br>10.4 编程示例 52<br>第十一章 Openssl大数 55<br>11.1 介绍 55<br>11.2 openssl大数表示 55<br>11.3 大数函数 55<br>11.4 使用示例 58<br>第十二章 Openssl base64编解码 65<br>12.1 BASE64编码介绍 65<br>12.2 BASE64编解码原理 65<br>12.3 主要函数 66<br>12.4 编程示例 66<br>第十三章 Openssl ASN1库 69<br>13.1 ASN1简介 69<br>13.2 DER编码 70<br>13.3 ASN1基本类型示例 71<br>13.4 openssl 的ASN.1库 73<br>13.5 用openssl的ASN.1库DER编码 74<br>13.6 Openssl的ASN.1宏 75<br>13.7 ASN1常用函数 76<br>13.8 属性证书编码 90<br>第十四章 Openssl错误处理 94<br>14.1 概述 94<br>14.2 数据结构 94<br>14.3 主要函数 96<br>14.4 编程示例 98<br>第十五章 Openssl摘要与HMAC 101<br>15.1 概述 101<br>15.2 openssl摘要实现 101<br>15.3 函数说明 101<br>15.4 编程示例 102<br>15.5 HMAC 103<br>第十六章 Openssl数据压缩 105<br>16.1 简介 105<br>16.2 数据结构 105<br>16.3 函数说明 106<br>16.4 openssl中压缩算法协商 106<br>16.5 编程示例 107<br>第十七章 Openssl RSA 108<br>17.1 RSA介绍 108<br>17.2 openssl的RSA实现 108<br>17.3 RSA签名与验证过程 109<br>17.4 数据结构 109<br>17.4.1 RSA_METHOD 109<br>17.4.2 RSA 110<br>17.5 主要函数 111<br>17.6编程示例 112<br>17.6.1密钥生成 112<br>17.6.2 RSA加解密运算 114<br>17.6.3签名与验证 117<br>第十八章 Openssl DSA 120<br>18.1 DSA简介 120<br>18.2 openssl的DSA实现 120<br>18.3 DSA数据结构 121<br>18.4 主要函数 122<br>18.5 编程示例 123<br>18.5.1密钥生成 123<br>18.5.2签名与验证 124<br>第十九章Openssl DH 127<br>19.1 DH算法介绍 127<br>19.2 openssl的DH实现 127<br>19.3数据结构 128<br>19.4 主要函数 129<br>19.5 编程示例 130<br>第二十章 Openssl椭圆曲线 133<br>20.1 ECC介绍 133<br>20.2 openssl的ECC实现 133<br>20.3 主要函数 134<br>20.4 编程示例 134<br>第二十一章 Openssl EVP 138<br>21.1 EVP简介 138<br>21.2 数据结构 138<br>21.2.1 EVP_PKEY 138<br>21.2.2 EVP_MD 139<br>21.2.3 EVP_CIPHER 140<br>21.2.4 EVP_CIPHER_CTX 141<br>21.3 源码结构 141<br>21.4 摘要函数 142<br>21.5 对称加解密函数 142<br>21.6 非对称函数 143<br>21.7 BASE64编解码函数 144<br>21.8其他函数 144<br>21.9 对称加密过程 146<br>21.10 编程示例 147<br>第二十二章 Openssl PEM格式 154<br>22.1 PEM概述 154<br>22.2 openssl的PEM实现 154<br>22.3 PEM函数 155<br>22.4 编程示例 156<br>第二十三章 Openssl Engine 160<br>23.1 Engine概述 160<br>23.2 Engine支持的原理 160<br>23.3 Engine数据结构 160<br>23.4 openssl 的Engine源码 161<br>23.5 Engine函数 162<br>23.6 实现Engine示例 163<br>第二十四章 Openssl 通用数据结构 177<br>24.1通用数据结构 177<br>24.2 X509_ALGOR 177<br>24.3 X509_VAL 178<br>24.4 X509_SIG 180<br>24.5 X509_NAME_ENTRY 181<br>24.6 X509_NAME 181<br>24.7 X509_EXTENSION 187<br>24.8 X509_ATTRIBUTE 193<br>24.9 GENERAL_NAME 195<br>第二十五章 Openssl 证书申请 198<br>25.1 证书申请介绍 198<br>25.2 数据结构 198<br>25.3 主要函数 199<br>25.4 编程示例 201<br>25.4.1生成证书请求文件 201<br>25.4.2 解码证书请求文件 203<br>第二十六章 Openssl X509数字证书 205<br>26.1 X509数字证书 205<br>26.2 opessl实现 205<br>26.3 X509数据结构 205<br>26.4 X509_TRUST与X509_CERT_AUX 208<br>26.5 X509_PURPOSE 210<br>26.6 主要函数 213<br>26.7 证书验证 216<br>26.7.1证书验证项 216<br>26.7.2 Openssl中的证书验证 216<br>第二十七章 Openssl OCSP 217<br>27.1 概述 217<br>27.2 openssl实现 217<br>27.3 主要函数 217<br>27.4编程示例 222<br>第二十八章 Openssl CRL 223<br>28.1 CRL介绍 223<br>28.2 数据结构 223<br>28.3 CRL函数 224<br>28.4 编程示例 226<br>第二十九章 Openssl PKCS7 228<br>29.1概述 228<br>29.2 数据结构 228<br>29.3 函数 229<br>29.4 消息编解码 229<br>29.4.1 data 230<br>29.4.2 signed data 230<br>29.4.3 enveloped 231<br>29.4.4 signed_and_enveloped 232<br>29.4.5 digest 233<br>29.4.6 encrypted 233<br>29.4.7 读取PEM 234<br>29.4.8 解码pkcs7 235<br>第三十章 Openssl PKCS12 236<br>30.1 概述 236<br>30.2 openss实现 236<br>30.3数据结构 236<br>30.4函数 237<br>30.5 编程示例 239<br>第三十一章 Openssl SSL实现 249<br>31.1概述 249<br>31.2 openssl实现 249<br>31.3 建立SSL测试环境 249<br>31.4 数据结构 250<br>31.5 加密套件 251<br>31.6 密钥信息 252<br>31.7 SESSION 252<br>31.8 多线程支持 253<br>31.9 编程示例 253<br>31.10 函数 264<br>第三十二章 Openssl命令 267<br>32.1概述 267<br>32.2 asn1parse 267<br>32.3 dgst 269<br>32.4 gendh 270<br>32.5 passwd 270<br>32.6 rand 271<br>32.7 genrsa 271<br>32.8 req 272<br>32.9 x509 274<br>32.10 version 277<br>32.11 speed 277<br>32.12 sess_id 278<br>32.13 s_server 278<br>32.14 s_client 280<br>32.15 rsa 282<br>32.16 pkcs7 283<br>32.17 dsaparam 284<br>32.18 gendsa 284<br>32.19 enc 285<br>32.20 ciphers 286<br>32.21 CA 287<br>32.22 verify 291<br>32.23 rsatul 292<br>32.24 crl 293<br>32.25 crl2pkcs7 294<br>32.26 errstr 294<br>32.27 ocsp 295<br>32.28 pkcs12 298<br>32.29 pkcs8 300<br>32.30 s_time 301<br>32.31 dhparam和dh 302<br>32.32 ecparam 303<br>32.33 ec 304<br>32.34 dsa 305<br>32.35 nseq 306<br>32.36 prime 307<br>32.37 smime 307

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值