0
votes

I am trying to consume Rest API in oracle procedure. I have created ACL entry as well as Added the SSL certificate to my oracle wallet manager. but when i am trying to execute the procedure i am getting the error as "ORA-29024: Certificate validation failure". Following is the code for my oracle procedure.

create or replace procedure TABADUL_TAS_AUTHENTICATION
 is
  req utl_http.req;
  res utl_http.resp;
  value VARCHAR2(1024);
  value1 VARCHAR2(1024);
  url varchar2(4000) := 'https://tapis.fasah.sa/tabadul/fasahqa/authorization/token';
  name varchar2(4000);
  buffer varchar2(4000); 
  content varchar2(4000) := '{"username":"ijsnj001","password":"P@ssw0rd"}';

begin
 UTL_HTTP.set_wallet('file:d:\tabadul', 'tas123456');
 req := utl_http.begin_request(url, 'POST',' HTTP/1.1');
  utl_http.set_header(req, 'user-agent', 'mozilla/4.0');
  utl_http.set_header(req, 'content-type', 'application/json;charset=utf-8');
  utl_http.set_header(req,'X-IBM-Client-Id','00a2f36e933e2bb9edc76faaf26659eb');
  utl_http.set_header(req,'X-IBM-Client-Secret','7c2829bd6b287b072ee269c9ad8f5ead');
  utl_http.set_header(req,'Accept-Language','en');
  utl_http.set_header(req,'Accept','application/json');

  utl_http.set_header(req, 'Content-Length', length(content));
  utl_http.write_text(req, content);
  res := utl_http.get_response(req);
  -- process the response from the HTTP call
  DBMS_OUTPUT.PUT_LINE('HTTP response status code: ' || res.status_code);
  --DBMS_OUTPUT.PUT_LINE('HTTP response reason phrase: ' || res.reason_phrase);

  FOR i IN 1..UTL_HTTP.GET_HEADER_COUNT(res) LOOP
    UTL_HTTP.GET_HEADER(res, i, name, value1);
    --DBMS_OUTPUT.PUT_LINE(name || ': ' || value1);
  END LOOP;

  --dbms_output.put_line(content);
  --dbms_output.put_line(utl_http.resp);
  begin
    loop
    --dbms_output.put_line('A');
      utl_http.read_line(res, value, true);
      --dbms_output.put_line(length(value));
      dbms_output.put_line(value);
      --INSERT INTO A VALUES (VALUE);
      --COMMIT;
    end loop;
    utl_http.end_response(res);
  exception
    when utl_http.end_of_body 
    then
      --dbms_output.put_line(SQLCODE||','||SQLERRM);
      utl_http.end_response(res);

    when others then
    --dbms_output.put_line(SQLCODE||','||SQLERRM);
      utl_http.end_response(res);
  end;
end TABADUL_TAS_AUTHENTICATION;
1

1 Answers

0
votes

This issue has been resolved.I am writing the solution here, it might be helpful for others. So instead of creating wallet for the actual website certificate, need to create wallet only for chain of certificate.