Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Security / March 2006

Tip: Looking for answers? Try searching our database.

connect to https and store certification key

Thread view: 
NOVA - 11 Mar 2006 11:20 GMT
Hi all,

I want code to connect to https by using httpunit

it is  possible to get source code of http page by usin URLConnection
class
by this code :
try {
       URL url = new
URL("https://hronline.aramco.com.sa/sec/login.asp");
       URLConnection uc = url.openConnection();
       uc.connect();
           BufferedReader in = new BufferedReader(new
InputStreamReader(uc.getInputStream()));
            String inputLine;
            while ((inputLine = in.readLine()) != null)
                System.out.println(inputLine);
            in.close();

   }         catch(UnknownHostException e){
            System.out.println(e + "***one***");
            System.out.println("must be on line to properly.");
        }
        catch(MalformedURLException e){
            System.out.println(e + "***two***");
        }
        catch(IOException e){
            System.out.println(e + "***three***");
        }

and to take source code of https by using URLConnection class, I just
add this code

TrustManager[] trustAllCerts = new TrustManager[]{
   new X509TrustManager() {
       public java.security.cert.X509Certificate[]
getAcceptedIssuers() {
           return null;
       }
       public void checkClientTrusted(
           java.security.cert.X509Certificate[] certs, String
authType) {
       }
       public void checkServerTrusted(
           java.security.cert.X509Certificate[] certs, String
authType) {
       }
   }
};

// Install the all-trusting trust manager
try {
   SSLContext sc = SSLContext.getInstance("SSL");
   sc.init(null, trustAllCerts, new java.security.SecureRandom());

HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
} catch (Exception e){}

but in httpunit that is not happen
so, i should add certification key manully by export the file from
explorer browser
then add it to file in
java_src\jre\lib\security\cacerts

until this point is ok

What I want?
Is that possible to write java code to do store the certification when
I connection with https directly?

thanks,
NOVA - 13 Mar 2006 14:00 GMT
is that possible??!!
no answer !!!!

I tried read all topic that dependent to my topic
but i am not understand

please
any answer.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.