我在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;
当我运行此代码时,我收到以下错误
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'protocole引起的。所以我下载了所有相关证书,然后交给我们的数据库团队。虽然他们已经使用这些证书配置了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.
请注意,我已经厌倦了所有格式的证书文件(Base-64编码/ PKCS#7等),如http://oracle-base.com/articles/misc/utl_http-and-ssl.php
中所述有什么想法?
答案 0 :(得分: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
这允许Oracle通过http与stunnel进行通信,然后stunnel与https://somesite.com进行通信,并将数据传送回端口80上的oracle。
这完全绕过了Oracle Wallet。
由于这不是您问题的直接答案,因此它确实解决了Oracle Wallet的许多问题,我认为这是最佳解决方案。