0

当我执行以下涉及 UTL_HTTP.REQUEST 调用的语句时,我得到ORA-29024: Certificate validation failure

SELECT UTL_HTTP.REQUEST('https://www.google.com') from DUAL;

ORA-29273: HTTP request failed 
ORA-06512: at "SYS.UTL_HTTP", line 1620 
ORA-29024: Certificate validation failure 
ORA-06512: at "SYS.UTL_HTTP", line 380 
ORA-06512: at "SYS.UTL_HTTP", line 1560 
ORA-06512: at line 1

根据自治数据库文档,UTL_HTTP 是受支持的 PL/SQL 包之一。为什么这个查询不起作用?

4

1 回答 1

0

此错误是由于未完成自治数据库中 UTL_HTTP 的先决条件步骤造成的。如文档中的示例所述,在调用 UTL_HTTP.REQUEST() 过程之前,我们需要首先通过 DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE() 为主机创建访问控制列表 (ACL),并通过 UTL_HTTP.SET_WALLET 设置钱包位置():

-- Create an Access Control List for the host
BEGIN
   DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
         host => 'www.google.com',
         ace =>  xs$ace_type(privilege_list => xs$name_list('http'),
                             principal_name => 'ADMIN',
                             principal_type => xs_acl.ptype_db));
END;
/

PL/SQL procedure successfully completed.

-- Set Oracle Wallet location (no arguments needed)
BEGIN
   UTL_HTTP.SET_WALLET('');
END;
/

PL/SQL procedure successfully completed.

SELECT UTL_HTTP.REQUEST('https://www.google.com') from DUAL;

utl_http.request('https://www.google.com')
-------------------------------------------------------------------------------------
<!doctype html><html itemscope="" itemtype="http://schema.org/WebPage" lang="en"> ...

免责声明:我是 Oracle 的产品经理。

于 2021-11-24T21:17:42.760 回答