Topic
10 replies Latest Post - ‏2010-10-21T11:30:01Z by Linda.Springfield
SystemAdmin
SystemAdmin
2262 Posts
ACCEPTED ANSWER

Pinned topic unknown protocol https

‏2003-12-08T21:28:20Z |
Need help!

Getting the following error when I try and run a simple program.

Exception in thread "main" java.net.MalformedURLException: unknown protocol https
at java.net.URL.<init>(URL.java(Compiled Code))
at java.net.URL.<init>(URL.java:399)
at java.net.URL.<init>(URL.java:353)
at TestURL.main(TestURL.java:7)

This is running on an AIX v4.3.3 machine.
I have downloaded and installed the IBM 1.3.1 SDK.
I have also installed the JSSE from IBM and verified the ibmjsse.jar, jnet.jar and jcert.jar files are in the /usr/java131/jre/lib/ext directory.

I have modified the /usr/java131/jre/lib/security/java.security file to have the following providers....

security.provider.1=sun.security.provider.Sun
security.provider.2=com.ibm.net.ssl.internal.ssl.Provider
security.provider.3=com.ibm.crypto.provider.IBMJCE
security.provider.4=com.ibm.jsse.IBMJSSEProvider

Here's the Program Source Code...

import java.io.*;
import java.net.*;
import com.ibm.net.ssl.*;

public class TestURL {
public static void main(String[] args) throws Exception {
URL url = new URL("https://www.verisign.com/");
URLConnection uc = url.openConnection();
BufferedReader in = new BufferedReader(
new InputStreamReader(
uc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}

Any help would be GREATLY appreciated!
Thanks
Updated on 2010-10-21T11:30:01Z at 2010-10-21T11:30:01Z by Linda.Springfield
  • SystemAdmin
    SystemAdmin
    2262 Posts
    ACCEPTED ANSWER

    Re: unknown protocol https

    ‏2003-12-15T11:14:56Z  in response to SystemAdmin
    Have you tried setting java.protocol.handler.pkgs=com.ibm.net.ssl.internal.www.protocol ?
    Failing that a 1.4.x SDK should be considered
    • SystemAdmin
      SystemAdmin
      2262 Posts
      ACCEPTED ANSWER

      Re: unknown protocol https

      ‏2004-01-19T15:39:29Z  in response to SystemAdmin
      So how do we consider SDK 1.4.x in WebSphere Studio App Dev?
  • SystemAdmin
    SystemAdmin
    2262 Posts
    ACCEPTED ANSWER

    Re: unknown protocol https

    ‏2004-01-18T05:54:56Z  in response to SystemAdmin
    you've statically identified your provider... but when you create the URL you need to reference your new url info like:
    ("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
  • SystemAdmin
    SystemAdmin
    2262 Posts
    ACCEPTED ANSWER

    Re: unknown protocol https

    ‏2004-01-18T05:56:51Z  in response to SystemAdmin
    Sorry...
    like this :
    System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol");
    • SystemAdmin
      SystemAdmin
      2262 Posts
      ACCEPTED ANSWER

      Re: unknown protocol https

      ‏2004-09-29T17:05:11Z  in response to SystemAdmin
      hi

      we've got the same problem and it hurts. Did you find a solution to that? Or die you even happen to have a sample client???

      help ist highly welcome - were desperate...
      J
      • SystemAdmin
        SystemAdmin
        2262 Posts
        ACCEPTED ANSWER

        Re: unknown protocol https

        ‏2004-10-06T21:52:01Z  in response to SystemAdmin
        Hi,
        What version of WebSphere application server you are using? If it is WAS5.*, it comes with its own JSSE package implementations and provider. Its been tough to use sun's JSSE in WAS environment. If you want to use the IBM JSSE provider , please execute the following code before you open any https URL connection.

        ************************************************************

        if (Security.getProvider("com.ibm.jsse.IBMJSSEProvider") == null)
        {
        java.security.Security.addProvider(new com.ibm.jsse.IBMJSSEProvider());
        }

        System.setProperty("java.protocol.handler.pkgs", "com.ibm.net.ssl.internal.www.protocol");

        SSLContext sslContext=null;
        javax.net.ssl.SSLSocketFactory sf = (javax.net.ssl.SSLSocketFactory)javax.net.ssl.SSLSocketFactory.getDefault();
        javax.net.ssl.HttpsURLConnection.setDefaultHostnameVerifier(new MyHostNameVerifier());
        MyTrustManager trustManager = new MyTrustManager();
        MyTrustManager[] trustManagerArray = {trustManager};
        KeyManager [] keyManager = null;
        sslContext = SSLContext.getInstance("SSL");
        sslContext.init(keyManager,trustManagerArray, new java.security.SecureRandom());
        sf = sslContext.getSocketFactory();
        HttpsURLConnection.setDefaultSSLSocketFactory(sf);

        ******************************************************

        class MyTrustManager implements X509TrustManager
        {
        public void checkClientTrusted( X509Certificate[] cert, String str)
        {
        }
        public void checkServerTrusted( X509Certificate[] cert, String str)
        {

        }
        public X509Certificate[] getAcceptedIssuers()
        {
        return null;
        }

        }

        **************************************************

        class MyHostNameVerifier implements HostnameVerifier
        {
        public boolean verify(String urlHostName, SSLSession ssl)
        {
        //uncomment these if you want to verify the hostname of the
        //certificate against the host name of the requested URL.
        //if(urlHostName.equals(certHostName))
        //return true;
        //else

        return true;
        }
        }

        **********************************************************
        • SystemAdmin
          SystemAdmin
          2262 Posts
          ACCEPTED ANSWER

          Re: unknown protocol https

          ‏2005-04-12T03:29:39Z  in response to SystemAdmin
          Hi,

          Download or take jsse.jar and Jce.jar from Sun jdk 1.4.x and copy to /WebSphere/AppServer/java/jre/lib/ext directory.

          Restart the server once .

          Above steps worked for me.
          Note. IBM JDK's jsse.jar and jce.jar has to be in jre/lib directory.
          • vijaygowda
            vijaygowda
            1 Post
            ACCEPTED ANSWER

            Re: unknown protocol https

            ‏2010-08-06T04:30:10Z  in response to SystemAdmin
            hi thanks...
            after putting jsse.jar and jce.jar from Sun jdk 1.4 x in my WebSphere/AppServer/java/jre/lib/ext, it worked for me
  • slicegan
    slicegan
    1 Post
    ACCEPTED ANSWER

    Re: unknown protocol https

    ‏2010-08-20T11:11:47Z  in response to SystemAdmin
    This works for me!

    URL url = new URL("https://www.paypal.com");

    URLConnection connection = url.openConnection();

    InputStream is = connection.getInputStream();

    byte[] buffer = new byte1024;

    for (int count = 0; (count = is.read(buffer)) >= 0; )

    {

    System.out.write(buffer, 0, count);

    }

    is.close();
    ================

    [url=http://www.guardianinsurance.com.au/Insurance.aspx] Insurance[/url] |[url=http://www.guardianinsurance.com.au/Accident-Insurance.aspx] Accident Insurance[/url]
  • Linda.Springfield
    Linda.Springfield
    1 Post
    ACCEPTED ANSWER

    Re: unknown protocol https

    ‏2010-10-21T11:30:01Z  in response to SystemAdmin
    slicegan wrote:
    This works for me!

    URL url = new URL("https://www.paypal.com");

    URLConnection connection = url.openConnection();

    InputStream is = connection.getInputStream();

    byte[] buffer = new byte1024;

    for (int count = 0; (count = is.read(buffer)) >= 0; )

    {

    System.out.write(buffer, 0, count);

    }

    is.close();
    ================

    [url=http://www.guardianinsurance.com.au/Insurance.aspx] Insurance[/url] |[url=http://www.guardianinsurance.com.au/Accident-Insurance.aspx] Accident Insurance[/url]

    The link you provided is very useful, Now I understand more about it.