【问题标题】:Certificate sent by the other side could not be validated - Oracle Wallet对方发送的证书无法验证 - Oracle Wallet
【发布时间】:2015-10-28 18:53:26
【问题描述】:

我在 PL/SQL 中编写了以下代码,用于从 Oracle 11g 调用第 3 方 API。

Begin

  -- preparing Request...
  l_http_request := UTL_HTTP.begin_request ('https://www..........'
                                          , 'GET'
                                          , 'HTTP/1.1');   
  -- set header's attributes...                                          
  UTL_HTTP.set_header(l_http_request, 'Content-Type', 'application/json');
  UTL_HTTP.set_header(l_http_request, 'Content-Length', LENGTH(t_request_body));
  UTL_HTTP.set_header(l_http_request, 'Api-Key','..............');

  -- get Response and obtain received value
  l_http_response := UTL_HTTP.get_response(l_http_request);

  UTL_HTTP.read_text(l_http_response, l_response_text);

end;

运行此代码时出现以下错误

Error report:
ORA-29273: HTTP request failed
ORA-06512: at "SYS.UTL_HTTP", line 1130
ORA-29024: Certificate validation failure
ORA-06512: at line 13
29273. 00000 -  "HTTP request failed"
*Cause:    The UTL_HTTP package failed to execute the HTTP request.
*Action:   Use get_detailed_sqlerrm to check the detailed error message.
           Fix the error and retry the HTTP request.

我发现这是由“https”协议引起的。所以我下载了所有相关的证书,然后交给我们的数据库团队。尽管他们已经使用这些证书配置了 Oracle 钱包,但我们仍然收到相同的错误报告。

有什么想法吗?

更新: 我在开始块的第一行添加了以下代码...

  UTL_HTTP.SET_DETAILED_EXCP_SUPPORT(TRUE); 
  UTL_HTTP.SET_WALLET('file:/../wallet','pwd.....' );

但现在它给出了以下异常“证书无效”,尽管证书发送者确认其有效性。也可以通过查看这个外部 ssl 检查器来确认有效性:https://www.sslshopper.com

Error report:
ORA-29024: Certificate validation failure
ORA-06512: at "SYS.UTL_HTTP", line 1128
ORA-06512: at line 16
29024. 00000 -  "Certificate validation failure"
*Cause:    The certificate sent by the other side could not be validated. This may occur if
           the certificate has expired, has been revoked, or is invalid for another reason.
*Action:   Check the certificate to determine whether it is valid. Obtain a new certificate,
           alert the sender that there certificate has failed, or resend.

请注意,如http://oracle-base.com/articles/misc/utl_http-and-ssl.php 中所述,我已经厌倦了所有格式的证书文件(Base-64 编码/PKCS#7 等)

有什么想法吗?

【问题讨论】:

  • 看到这个帖子:stackoverflow.com/a/16081869/92837
  • @Sathya,在那篇文章中,他们已将钱包设置为调用 pl sql 代码,例如 EXEC UTL_HTTP.set_wallet('file:/u01/app/oracle/admin/DB11G/wallet', 'WalletPasswd123' );是必须的吗?
  • 数据库的哪个精确版本?是否已完全修补?您使用的是哪个协议/版本:SSLv3? TSLv1?还有什么?
  • @APC,Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production,PL/SQL Release 11.2.0.3.0 - Production,“CORE 11.2.0.3.0 Production”,TNS for Linux:版本 11.2.0.3.0 - 生产,NLSRTL 版本 11.2.0.3.0 - 生产,TLS 版本是 1.2,SSL 版本是 v3
  • 我觉得你需要设置钱包:utl_http.set_wallet(wallet_path, wallet_password);

标签: sql oracle rest ssl plsql


【解决方案1】:

就个人而言,我发现在 Oracle 钱包中加载您想要访问的每个网站的证书很痛苦(这可能是您收到错误的原因 - 您需要安装证书和链您尝试访问电子钱包的网站)。

最简单的方法是安装 stunnel https://www.stunnel.org/index.html

配置 stunnel 以侦听本地端口(例如 8800)上的传入连接,然后与 somesite.com:443 建立出站连接。

类似这样的:

1.  oracle issues a get as: http://localhost:8080/index.html
2.  stunnel intercepts the request and gets https://somesite.com/index.html
3.  stunnel gives results to oracle 

这允许 Oracle 通过 http 与 stunnel 通信,然后 stunnel 与https://somesite.com 通信并将数据通过端口 80 传递回 oracle。

这完全绕过了 Oracle Wallet。

由于这不是您问题的直接答案,它肯定解决了 Oracle Wallet 的许多问题,并且在我看来是最好的解决方案。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-26
    • 2018-10-03
    • 2019-03-19
    相关资源
    最近更新 更多