[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[iaik-ssl] NullPointerException while opening InputStream



My code is as shown below:
 
import java.net.*;
import java.io.*;
import java.security.*;
import java.security.cert.*;
import com.sun.net.ssl.*;
import javax.net.ssl.*;
import javax.security.cert.*;
import javax.net.*;
import iaik.security.provider.IAIK;
import iaik.pkcs.pkcs12.*;
import iaik.pkcs.*;
import iaik.security.ssl.*;
import iaik.protocol.https.*;
 
public class httpsTest{
 
 public httpsTest() {}
 
 public static void main(String args[]){
 
httpsTest i_test = new httpsTest();
 
  System.getProperties().put( "proxySet", "true" );
  System.getProperties().put( "https.proxyHost",
proxy);
  System.getProperties().put( "https.proxyPort", port
);
 
System.setProperty("javax.net.ssl.trustStore","c:\\jdk1.2.2\\jre\\lib\\security\\cacerts");
 
System.getProperties().put("java.protocol.handler.pkgs",
"iaik.protocol");
 
  try{
System.out.println("1");
   IAIK.addAsProvider();
   FileInputStream xis = new
FileInputStream("c:\\jdk1.2.2\\jre\\lib\\security\\test.pfx");
   PKCS12 p12 = new PKCS12(xis);
   p12.decrypt("changeit".toCharArray());
System.out.println("2");
   java.security.cert.X509Certificate[] cert =
CertificateBag.getCertificates(p12.getCertificateBags());
   PrivateKey privKey =
p12.getKeyBag().getPrivateKey();
System.out.println("3");
   SSLClientContext sc1 = new SSLClientContext();
   sc1.addClientCredentials(cert, privKey);
   sc1.setCheckExportRestrictions(true);
System.out.println("4");
   URL i_url = new
URL("https://www.somesite.com/blank.html");
   iaik.protocol.https.HttpsURLConnection con = new
iaik.protocol.https.HttpsURLConnection(i_url);
System.out.println("5");
   con.setSSLContext(sc1);
System.out.println(con.getRequestMethod());
System.out.println("6");
   InputStream inn = con.getInputStream();
   BufferedReader in = new BufferedReader( new
InputStreamReader(inn));
System.out.println("7");
   String inputLine;
   while ((inputLine = in.readLine()) != null)
    System.out.println(inputLine);
   in.close();
  }catch (Exception e)
{System.out.println(e.toString());}
 }
}
 
The getRequestMethod returns "GET"
After Stage 6, when the InputStream is initiated, the
application exits with the exception:
java.lang.NullPointerException
What am I doing wrong here? Please Help.

__________________________________________________
Do You Yahoo!?
Get Yahoo! Mail  Free email you can access from anywhere!
http://mail.yahoo.com/
--
Mailinglist-archive at http://jcewww.iaik.at/mailarchive/iaik-ssl/sslthreads.html

To unsubscribe send an email to listserv@iaik.at with the folowing content: UNSUBSCRIBE iaik-ssl