ACL

ORA-24247 - network access denied by access control list (ACL)

ACL = Access Control List è la lista degli utenti che possono accedere ad host esterni tramite risorse di rete UTL_TCP, UTL_SMTP, UTL_MAIL and UTL_HTTP usando diverse PL/SQL APIs.


Attraverso le seguenti procedure viene caricato la lista nel XML DB repository.

  1. Creare il file acl.

BEGIN

DBMS_NETWORK_ACL_ADMIN.create_acl (

  acl          => '/sys/acls/<nome_acl>.xml',

  description  => 'ACL /sys/acls/<nome_acl>.xml',

  principal    => 'SYS',

  is_grant     => true,

  privilege    => 'connect');

COMMIT;

END;


acl: è il nome del file ACL XML e la directory dove viene generato

description: è la descrizione dell’acl

principal: indica il primo user o ruolo che ha i privilegi

is_grant: indica se quell’utente può avere i privilegi o meno

privilege: connect è il privilegio dell’utente sys può accedere ai servizi di rete UTL_TCP, UTL_SMTP, UTL_MAIL and UTL_HTTP usando diverse PL/SQL APIs.


2) Aggiungere utenti o ruoli 

BEGIN
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(
  acl         => '/sys/acls/<nome_acl>.xml',

  principal   => '<schema>',
  is_grant    => true,
  privilege   => 'connect');
COMMIT;
END;


BEGIN

DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(

  acl         => '/sys/acls/<nome_acl>.xml',

  principal   => '<schema>',

  is_grant    => true,

  privilege   => 'resolve');

COMMIT;

end;

Ogni principal è definito all’interno del file  come un separato ACE (access control element) e pertanto sono definiti in ordine top to bottom. 

3) Assegnare il file Acl.xml all’ host e l’intervallo di porte.

BEGIN

DBMS_NETWORK_ACL_ADMIN.assign_acl  (

   acl         => '/sys/acls/<nome_acl>.xml',

   host        => '*',

   lower_port  => '',

   upper_port  => '');

COMMIT;

END;


Verifica delle proprietà dall’ACL.

  • Contiene informazioni sull'assegnazione della rete all'ACL

select * from DBA_NETWORK_ACLS;

  • Contiene informazioni sul principal

select * from   DBA_NETWORK_ACL_PRIVILEGES;

  • Contiene informazioni sull'attuale configurazione del network ACL

select * from USER_NETWORK_ACL_PRIVILEGES;


TEST che l’utente può utilizzare il servizio di rete UTL_HTTP usando l’API PL/SQL.

alter session set current_schema = <schema>; 

select sys_context ('userenv','current_schema') from dual;

SELECT UTL_HTTP.REQUEST('http://www.google.com') from dual;


DECLARE

  l_url            VARCHAR2(50) := 'http://www.google.com';

  l_http_request   UTL_HTTP.req;

  l_http_response  UTL_HTTP.resp;

BEGIN

  -- Make a HTTP request and get the response.

  l_http_request  := UTL_HTTP.begin_request(l_url);

  l_http_response := UTL_HTTP.get_response(l_http_request);

  UTL_HTTP.end_response(l_http_response);

END;

/


La procedura deve compilare.

Se si esegue la seguente query ad una url https

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

ORA-29273: richiesta HTTP non riuscita

ORA-06512: a "SYS.UTL_HTTP", line 1720

ORA-12545: Connessione non riuscita perché l'host o l'oggetto di destinazione non esiste

ORA-06512: a line 1

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.


Questo vuol dire che HTTPS non funziona .

Per abilitare l'accesso HTTPS dal pacchetto UTL_HTTP occorre installare un WALLET che permette di gestire i certificati.


Post popolari in questo blog

Create e Drop Pluggable Database

ORA-12154: TNS: il listener non è attualmente a conoscenza del servizio richiesto nel descrittore di connessione