openssl的协议版本引起的问题curl: (35) error:0A000152:SSL routines::unsafe legacy renegotiation disabled

使用curl或者wget这样的命令出现这样的报错

curl: (35) error:0A000152:SSL routines::unsafe legacy renegotiation disabled

或者Run failed: [SSL: UNSAFE_LEGACY_RENEGOTIATION_DISABLED] unsafe legacy renegotiation disabled (_ssl.c:1010) 这样的报错
这个错误表明您的客户端(使用 OpenSSL 3.0+)尝试连接的服务器仍在使用不安全的传统 SSL/TLS 重新协商协议,而现代 OpenSSL 默认禁用了此功能。我使用的是3.0.15, 以下是分步解决方案:

vim /etc/ssl/openssl.cnf 

# requires this to avoid interpreting an end user certificate as a CA.

basicConstraints=CA:FALSE

# This is typical in keyUsage for a client certificate.
# keyUsage = nonRepudiation, digitalSignature, keyEncipherment

# PKIX recommendations harmless if included in all certificates.
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid,issuer

# This stuff is for subjectAltName and issuerAltname.
# Import the email address.
# subjectAltName=email:copy
# An alternative to produce certificates that aren't
# deprecated according to PKIX.
# subjectAltName=email:move

# Copy subject details
# issuerAltName=issuer:copy

# This really needs to be in place for it to be a proxy certificate.
proxyCertInfo=critical,language:id-ppl-anyLanguage,pathlen:3,policy:foo

####################################################################
[ tsa ]

default_tsa = tsa_config1	# the default TSA section

[ tsa_config1 ]

# These are used by the TSA reply generation only.
dir		= ./demoCA		# TSA root directory
serial		= $dir/tsaserial	# The current serial number (mandatory)
crypto_device	= builtin		# OpenSSL engine to use for signing
signer_cert	= $dir/tsacert.pem 	# The TSA signing certificate
					# (optional)
certs		= $dir/cacert.pem	# Certificate chain to include in reply
					# (optional)
signer_key	= $dir/private/tsakey.pem # The TSA private key (optional)
signer_digest  = sha256			# Signing digest to use. (Optional)
default_policy	= tsa_policy1		# Policy if request did not specify it
					# (optional)
other_policies	= tsa_policy2, tsa_policy3	# acceptable policies (optional)
digests     = sha1, sha256, sha384, sha512  # Acceptable message digests (mandatory)
accuracy	= secs:1, millisecs:500, microsecs:100	# (optional)
clock_precision_digits  = 0	# number of digits after dot. (optional)
ordering		= yes	# Is ordering defined for timestamps?
				# (optional, default: no)
tsa_name		= yes	# Must the TSA name be included in the reply?
				# (optional, default: no)
ess_cert_id_chain	= no	# Must the ESS cert id chain be included?
				# (optional, default: no)
ess_cert_id_alg		= sha1	# algorithm to compute certificate
				# identifier (optional, default: sha1)

[insta] # CMP using Insta Demo CA
# Message transfer
server = pki.certificate.fi:8700
# proxy = # set this as far as needed, e.g., http://192.168.1.1:8080
# tls_use = 0
path = pkix/

# Server authentication
recipient = "/C=FI/O=Insta Demo/CN=Insta Demo CA" # or set srvcert or issuer
ignore_keyusage = 1 # potentially needed quirk
unprotected_errors = 1 # potentially needed quirk
extracertsout = insta.extracerts.pem

# Client authentication
ref = 3078 # user identification
secret = pass:insta # can be used for both client and server side

# Generic message options
cmd = ir # default operation, can be overridden on cmd line with, e.g., kur

# Certificate enrollment
subject = "/CN=openssl-cmp-test"
newkey = insta.priv.pem
out_trusted = apps/insta.ca.crt # does not include keyUsage digitalSignature
certout = insta.cert.pem

[pbm] # Password-based protection for Insta CA
# Server and client authentication
ref = $insta::ref # 3078
secret = $insta::secret # pass:insta

[signature] # Signature-based protection for Insta CA
# Server authentication
trusted = $insta::out_trusted # apps/insta.ca.crt

# Client authentication
secret = # disable PBM
key = $insta::newkey # insta.priv.pem
cert = $insta::certout # insta.cert.pem

[ir]
cmd = ir

[cr]
cmd = cr

[kur]
# Certificate update
cmd = kur
oldcert = $insta::certout # insta.cert.pem

[rr]
# Certificate revocation
cmd = rr
oldcert = $insta::certout # insta.cert.pem

最后添加

openssl_conf = openssl_init

[openssl_init]
ssl_conf = ssl_sect

[ssl_sect]
system_default = system_default_sect

[system_default_sect]
Options = UnsafeLegacyServerConnect

然后重启服务即可

注意在 OpenSSL < 3.0.4 存在一个错误,会忽略UnsafeLegacyServerConnect选项。如果您使用的是<= 3.0.3版本,则可以使用(更不安全的)UnsafeLegacyRenegotiation代替。

这个错误信息"OpenSSL: error:0A000086:SSL routines::certificate verify failed:"通常出现在使用OpenSSL库进行SSL/TLS连接时,证书验证失败的情况下。这个错误可能由多种原因引起,以下是一些常见的原因和解决方法: 1. 系统时间不正确: 解决方法:确保系统时间是准确的,可以与网络时间服务器同步。 2. 根证书缺失或过期: 解决方法:更新系统的根证书库,确保包含了最新的根证书。 3. 服务器证书过期或无效: 解决方法:检查服务器证书的有效期和签名,确保证书是有效的。 4. 中间证书缺失: 解决方法:确保服务器配置了完整的中间证书链。 5. 主机名不匹配: 解决方法:验证证书中的域名与实际访问的域名是否一致。 6. SNI(服务器名称指示)配置问题: 解决方法:确保客户端正确设置了SNI,特别是在使用虚拟主机的情况下。 7. 客户端或服务器配置问题: 解决方法:检查OpenSSL配置,确保正确设置了受信任的证书颁发机构。 8. 防火墙或中间人攻击: 解决方法:确保没有防火墙或中间设备在拦截和修改SSL流量。 要解决这个问题,可以尝试以下步骤: 1. 更新系统根证书库 2. 检查服务器证书的有效性 3. 验证客户端和服务器OpenSSL配置 4. 使用OpenSSL命令行工具进行详细诊断 例如,可以使用以下命令来测试SSL连接: ``` openssl s_client -connect example.com:443 -showcerts ``` 这个命令会显示详细的SSL握手过程和证书信息,有助于进一步诊断问题
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值