SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

简介: 在文章 Ruby On Rails中REST API使用示例——基于云平台+云服务打造自己的在线翻译工具 中,利用ruby的Net::HTTP发起http请求访问IBM Bluemix上的语言翻译服务时,提示:SSL_connect returned=1 errno=0 state=SSLv3 ...

在文章 Ruby On Rails中REST API使用示例——基于云平台+云服务打造自己的在线翻译工具 中,利用ruby的Net::HTTP发起http请求访问IBM Bluemix上的语言翻译服务时,提示:SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

例如下面的代码:

		auth = "c9819718-4660-441c-9df7-07398950ea44:qUvrJPSadgOx";
		surl = "https://" + auth + "@gateway.watsonplatform.net/language-translation/api/v2/translate?source=en&target=es&text=" + @txt;
		uri = URI.parse(surl);		
			begin #开始
			http = Net::HTTP.new(uri.host, uri.port)
			http.use_ssl = true
			
			request = Net::HTTP::Get.new(uri.request_uri)
			
			response = http.request(request)
			@result = "{\"text\":\"#{response.body}\"}";
		rescue
			@result = "{\"error\":\"#{$!}!\"}";
		end
我们注意到,URL是HTTPS开头,需要设置:http.use_ssl = true

但只是设置了http.use_ssl = true,但不设置http.verify_mode的话,就会出现此错误;


设置方法:

如果你访问的地址不需要证书,设置如下:

http.verify_mode = OpenSSL::SSL::VERIFY_NONE


如果使用了证书,设置如下:

http.verify_mode = OpenSSL::SSL::VERIFY_PEER

https.ca_file = '/opt/local/share/curl/curl-ca-bundle.crt'

按我的理解应该是这样设置,具体还没 有测试过。


目录
相关文章
|
11月前
|
网络安全 Python
There was a problem confirming the ssl certificate
There was a problem confirming the ssl certificate
250 0
|
1月前
|
Java 关系型数据库 MySQL
记录解决一个小错误:Establishing SSL connection without server‘s identity verification is not recommended
本文记录了解决Spring Boot连接MySQL时出现的SSL连接警告问题的步骤,通过在数据源配置中添加`useSSL=false`来禁用SSL连接。
|
4月前
|
Shell 网络安全 开发工具
【已解决】SSL certificate problem: self signed certificate
SSL certificate problem: self signed certificate
166 2
|
2月前
|
Linux 网络安全 API
【Azure 环境】当在Azure 环境中调用外部接口不通时,如何定位SSL Certificate Problem
【Azure 环境】当在Azure 环境中调用外部接口不通时,如何定位SSL Certificate Problem
|
2月前
|
SQL 安全 Java
驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:“The server selected protocol version TLS10 is not accepted by client
驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:“The server selected protocol version TLS10 is not accepted by client
324 0
|
2月前
|
iOS开发 Perl
解決pod install报错:unable to access: LibreSSL SSL_read: error:Operation timed out, errno 60
解決pod install报错:unable to access: LibreSSL SSL_read: error:Operation timed out, errno 60
70 0
|
5月前
LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 60
LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 60
92 0
|
安全 网络安全 PHP
解决SSL routines:ssl3_get_server_certificate:certificate verify failed
解决SSL routines:ssl3_get_server_certificate:certificate verify failed
596 0
|
关系型数据库 MySQL 网络安全
Mysql高低版本切换需要修改的配置5-8(此处以aicode为例)(WARN: Establishing SSL connection without server‘s identity veri)
Mysql高低版本切换需要修改的配置5-8(此处以aicode为例)(WARN: Establishing SSL connection without server‘s identity veri)
113 0
|
5月前
|
网络安全 开发工具 git
解决 OpenSSL SSL_read: Connection was reset, errno 10054的问题
解决 OpenSSL SSL_read: Connection was reset, errno 10054的问题