Calling https from db

To invoke web service from oracle database is a bit complicated.

From user : HR ,  we're going to  invoke a web service from https://www.oracle.com .

Here are the steps to connect your oracle db to ssl websites :

1-Add your site to the ACL  :

login as sysdba : 

DECLARE
  ACL_PATH  VARCHAR2(4000);
BEGIN
  -- Look for the ACL currently assigned to 'localhost' and give APEX_050100
  SELECT ACL INTO ACL_PATH FROM DBA_NETWORK_ACLS
   WHERE HOST = 'localhost' AND LOWER_PORT IS NULL AND UPPER_PORT IS NULL;
   
  IF DBMS_NETWORK_ACL_ADMIN.CHECK_PRIVILEGE(ACL_PATH, 'HR',
     'connect') IS NULL THEN
      DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(ACL_PATH,
     'HR', TRUE, 'connect');
  END IF;
  
EXCEPTION
  -- When no ACL has been assigned to 'localhost'.
  WHEN NO_DATA_FOUND THEN
  DBMS_NETWORK_ACL_ADMIN.CREATE_ACL('local-access-users.xml',
    'ACL that lets users to connect to localhost',
    'HR', TRUE, 'connect');
  DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL('local-access-users.xml','localhost');
END;
/
COMMIT;
--where
---------HR : the user will consume webservice
---------*.oracle.com : site we'll call

BEGIN
    DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE (
        HOST   => '*.oracle.com',
        ace    =>
            xs$ace_type (privilege_list   => xs$name_list ('connect'),
                         principal_name   => 'HR',
                         principal_type   => xs_acl.ptype_db));
END;

COMMIT;

2-Modify the SQLNET.ORA and add the wallet location : 
wallet_location =source =(method = file)(method_data = (directory =c:\oracle\db_home\wallet\https_wallet)))

3- Download certificate files using firefox browser , you'll download two crt files  

4-Create empty wallet using Orapki tool :

5-Create Empty Wallet

orapki wallet create -wallet C:\oracle\db_home\wallet\https_wallet -pwd oracle123 -auto_login


6- Add first Certificate to Wallet

orapki wallet add -wallet C:\oracle\db_home\wallet\https_wallet  -cert 

C:\oracle\db_home\wallet\https_wallet\DigiCertTLS.crt -trusted_cert -pwd oracle123 


7- Add second Certificate to Wallet

orapki wallet add -wallet C:\oracle\db_home\wallet\https_wallet  -cert C:\oracle\db_home\wallet\https_wallet\DigiCertGlobalRootCA.crt -trusted_cert -pwd oracle123 

8- test your webservice now !



No comments:

Post a Comment

Remove unused Layouts in Oracle Apex

 Tables used : APEX_XXXXXXX.WWV_FLOW_REPORT_LAYOUTS APEX_XXXXXXX.WWV_FLOW_SHARED_QUERIES use the following query to delete unused Layouts. ...