【发布时间】: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 等)
有什么想法吗?
【问题讨论】:
-
@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);