gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 12:46:55 29 4
gpt4 key购买 nike

我在 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”协议(protocol)引起的。所以我下载了所有相关证书,然后交给了​​我们的数据库团队。尽管他们已经使用这些证书配置了 Oracle wallet,但我们仍然收到相同的错误报告。

有什么想法吗?

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

  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 中所述。

有什么想法吗?

最佳答案

就个人而言,我发现在 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 钱包。

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

关于sql - 无法验证对方发送的证书 - Oracle Wallet,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28824365/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com