无法验证对方发送的证书 - Oracle Wallet

CAD*_*CAD 5 sql oracle rest ssl plsql

我在PL/SQL中编写了以下代码,用于从Oracle 11g调用第三方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;
Run Code Online (Sandbox Code Playgroud)

当我运行此代码时,我遇到了以下错误

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.
Run Code Online (Sandbox Code Playgroud)

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

有什么想法吗?

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

  UTL_HTTP.SET_DETAILED_EXCP_SUPPORT(TRUE); 
  UTL_HTTP.SET_WALLET('file:/../wallet','pwd.....' );
Run Code Online (Sandbox Code Playgroud)

但现在它提供以下例外"证书无效",尽管证书发件人确认其有效性.此外,有效性也可以通过查看此外部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.
Run Code Online (Sandbox Code Playgroud)

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

有什么想法吗?

Bri*_*ity 1

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

最简单的事情是安装 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 
Run Code Online (Sandbox Code Playgroud)

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

这完全绕过了 Oracle 钱包。

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