Results 1 to 2 of 2
  1. #1
    dror is offline Member
    Join Date
    Jul 2012
    Posts
    2
    Rep Power
    0

    Default How to post HTTPS request

    Hi guys,
    Im trying also to post https request, but unfortunately it doesn't work.
    I creating a https server as follows:

    protected void createServer() throws IOException {
    InetSocketAddress address = new InetSocketAddress(this.host, this.port);

    this.requestHandler = new HttpsRequestsHandler();

    // Create a trust manager that does not validate certificate chains
    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) {
    }
    }
    };

    SSLContext ssl = null;
    // Install the all-trusting trust manager
    try {

    char[] KEYSTOREPW = "serverkspw".toCharArray(); //username
    char[] KEYPW = "serverpw".toCharArray(); //password
    String KEYSTORE = "certs";

    KeyStore keystore = KeyStore.getInstance("JKS");
    keystore.load(new FileInputStream("c://"+ KEYSTORE), KEYSTOREPW);

    KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
    kmf.init(keystore, KEYPW);

    ssl = SSLContext.getInstance("SSLv3");
    ssl.init(kmf.getKeyManagers(), null, null);
    HttpsURLConnection.setDefaultSSLSocketFactory(ssl. getSocketFactory());
    } catch (Exception e) {
    }


    try {
    HttpsServer newServer = HttpsServer.create(address,10);
    newServer.setHttpsConfigurator (new HttpsConfigurator(ssl) {
    public void configure (HttpsParameters params) {


    SSLContext c = getSSLContext();
    // get the default parameters
    SSLParameters sslparams = c.getDefaultSSLParameters();

    params.setSSLParameters(sslparams);

    }
    });

    Somebody please can tell me where i'm wrong? what i need to change?
    Thanks a lot!
    Dror.

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is online now Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,404
    Rep Power
    20

    Default Re: How to post HTTPS request

    Removed from How to post HTTPS request from java client to server . Don't post to old dead threads. That thread was five years old.

    Please go through all these:
    Forum Rules
    Guide For New Members
    BB Code List - Java Programming Forum

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Https post
    By dongorangoran in forum Networking
    Replies: 1
    Last Post: 02-21-2011, 03:11 PM
  2. HTTPS POST Using Java
    By drcman in forum Advanced Java
    Replies: 7
    Last Post: 02-13-2010, 02:19 PM
  3. How redirect a request to https
    By vns955 in forum Web Frameworks
    Replies: 1
    Last Post: 11-12-2009, 03:26 AM
  4. First post as per request
    By happyknappy in forum Introductions
    Replies: 3
    Last Post: 07-30-2008, 01:33 AM
  5. Replies: 1
    Last Post: 07-14-2007, 05:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •