Home » SQL & PL/SQL » SQL & PL/SQL » How can I pass UserId/Password securely as a parameter using UTL_HTTP (Oracle 11G Enterprise 11.2.0.4.0 - 64bit)
How can I pass UserId/Password securely as a parameter using UTL_HTTP [message #647339] Tue, 26 January 2016 16:57 Go to next message
kjcook
Messages: 31
Registered: January 2016
Member
With in my PLSQL package I am connecting to a Web Application to pull the content of a report. In order to do this I have to pass the UserId/Password as parameters in my URL. How can I do this securely? Currently the UserId/Password is being passed across the net in clear text. Here is a snippet of my code:

feedloc := 'https://111.11.11.11:8000/abc/clientLogin';
feedData := '&Email=XXXXXX&Passwd=XXXXXX';
req := UTL_HTTP.BEGIN_REQUEST (url=>feedLoc, method=>'POST');
UTL_HTTP.SET_HEADER ( req, 'Content-Type', 'application/x-www-form-urlencoded');
UTL_HTTP.SET_HEADER ( req, 'Content-Length', length(feedData) );
UTL_HTTP.WRITE_TEXT ( r => req,
data => feedData );
resp := UTL_HTTP.GET_RESPONSE(req);
LOOP
UTL_HTTP.READ_LINE(resp, rvalue, TRUE);
token := rvalue;
END LOOP;
UTL_HTTP.END_RESPONSE(resp);
return token;


The above code snippet does work, it is just not secure. How can I do it securely so the UserId/Password is not clear text?

Re: How can I pass UserId/Password securely as a parameter using UTL_HTTP [message #647342 is a reply to message #647339] Tue, 26 January 2016 18:54 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
> How can I do it securely so the UserId/Password is not clear text?
What make you think that HTTPS is NOT secure?

https://en.wikipedia.org/wiki/HTTPS
Re: How can I pass UserId/Password securely as a parameter using UTL_HTTP [message #647455 is a reply to message #647342] Thu, 28 January 2016 13:44 Go to previous messageGo to next message
kjcook
Messages: 31
Registered: January 2016
Member
HTTPS is secure. I am not questioning that. It is the call from Oracle's UTL_HTTP to the website https://111.11.11.11:8000/... that isn't secure. The userId/Password that is being passed as a parameter is clear text. Once on the website https://111.11.11.11:8000/... I am good, but getting there is the problem.

Any suggestions?
Re: How can I pass UserId/Password securely as a parameter using UTL_HTTP [message #647484 is a reply to message #647455] Fri, 29 January 2016 07:26 Go to previous messageGo to next message
ThomasG
Messages: 3211
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
So the problem is not that the password is "passed across the net" the problem is that the password is "stored inside the code".

One possible solution to that would be to "wrap" the packages that have passwords in them. (or create a dedicated "getpassword" function and wrap only that.

$ cat f.sql
CREATE OR replace function get_password return varchar2 is
begin
 return 'foobar';
end;
/

$ wrap iname=f.sql oname=f.plb

PL/SQL Wrapper: Release 11.2.0.3.0- 64bit Production on Fri Jan 29 14:23:35 2016

Copyright (c) 1993, 2009, Oracle.  All rights reserved.

Processing f.sql to f.plb

$ cat f.plb
CREATE OR replace function get_password wrapped
a000000
369
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
8
46 7d
Yf7O+veHkmbEmqecd0z3zJj6dgswg8eZgcfLCNL+XlquYvSWWlbR0XKW8sznwLK9spte58d0
wDO4dGUJpXSLwMAy/tKGrPpNsEPBSWxvJrrHvpK+VIKmph1bjgE=

/
$



[Updated on: Fri, 29 January 2016 07:26]

Report message to a moderator

Re: How can I pass UserId/Password securely as a parameter using UTL_HTTP [message #647485 is a reply to message #647484] Fri, 29 January 2016 08:03 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
Unfortunately the oracle wrapping protocol has been broken and it is easy to convert wrapped code back to clear text.
Re: How can I pass UserId/Password securely as a parameter using UTL_HTTP [message #647486 is a reply to message #647484] Fri, 29 January 2016 08:16 Go to previous messageGo to next message
kjcook
Messages: 31
Registered: January 2016
Member
sorry, I am not communicating this very well. The Oracle database has a function called UTL_HTTP. UTL_HTTP accepts several different parameters, one of which is the URL of a website that you want to read. The particular website that I am interested in reading, requires a UserId/Password. So I create the following URL ('https://111.11.11.11:8000/abc/clientLogin&Email=XXXXXX&Passwd=XXXXXX') and give it to the Oracle procedure utl_http which then tries to connect to the website and in doing so passes the userId/Password across the net as clear text. It is from the database (utl_http) to the website that the UserId/Password is being displayed as clear text.
Re: How can I pass UserId/Password securely as a parameter using UTL_HTTP [message #647487 is a reply to message #647486] Fri, 29 January 2016 08:20 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
Then use https from the beginning. See the following link

https://oracle-base.com/articles/misc/utl_http-and-ssl
Re: How can I pass UserId/Password securely as a parameter using UTL_HTTP [message #647488 is a reply to message #647487] Fri, 29 January 2016 08:28 Go to previous messageGo to next message
kjcook
Messages: 31
Registered: January 2016
Member
That example is going from a https enabled database to https website. I am going from a http database to a https website and even though the example in the webpage you sent me says it cant be done, it is working. It works great with one small draw back, my UserId/Password is being sent across the net as clear text.

So as you say "Then use https from the beginning", how do I enable my database to be https? What are the steps? I think I am asking the correct question.
Re: How can I pass UserId/Password securely as a parameter using UTL_HTTP [message #647489 is a reply to message #647488] Fri, 29 January 2016 08:44 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
To use https you need to have an oracle wallet defined and use the UTL_HTTP.set_wallet procedure in the code to use the certificate from the wallet. The fact that your call worked shows that the called website didn't use https, it reverted back to an http connection. Without a certificate defined in the oracle database it can't use https. You would see this if your internal web site was set to ONLY accept HTTPS connections.
Re: How can I pass UserId/Password securely as a parameter using UTL_HTTP [message #647507 is a reply to message #647489] Fri, 29 January 2016 15:27 Go to previous messageGo to next message
ThomasG
Messages: 3211
Registered: April 2005
Location: Heilbronn, Germany
Senior Member
There seems to be some kind of mix-up in the terminology.

Oracle Wallet would help you, if the server uses HTTP(S) authentication, basically when "the browser pops up a username/password" dialog when you try to access an URL.

In your case you pass username/password as part of the URL. When you use HTTPS, the URL is not passed across the net as clear text.

See http://en.wikipedia.org/wiki/HTTPS

Quote:
Because HTTPS piggybacks HTTP entirely on top of TLS, the entirety of the underlying HTTP protocol can be encrypted. This includes the request URL (which particular web page was requested), query parameters, headers, and cookies (which often contain identity information about the user). However, because host (website) addresses and port numbers are necessarily part of the underlying TCP/IP protocols, HTTPS cannot protect their disclosure. In practice this means that even on a correctly configured web server, eavesdroppers can infer the IP address and port number of the web server (sometimes even the domain name e.g. www.example.org, but not the rest of the URL) that one is communicating with as well as the amount (data transferred) and duration (length of session) of the communication, though not the content of the communication
Re: How can I pass UserId/Password securely as a parameter using UTL_HTTP [message #647510 is a reply to message #647507] Fri, 29 January 2016 16:04 Go to previous message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
Cool, nice to know. Thank you ThomasG
Previous Topic: How to capture particular column from select statement inside a package body in oracle pl sql
Next Topic: UTL_FILE Writeing in multiple text files
Goto Forum:
  


Current Time: Wed Apr 17 22:09:12 CDT 2024