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

[iaik-ssl] AW: HTTPS put Issue



Hello,

The maximum number of simultaneous connections can be configured via
System property "org.w3c.www.protocol.http.connections.max" (default 5).
(see class org.w3c.www.protocol.http.HttpManager which alllows to set
some other configuration options, too).

e.g.:

System.getProperties().put(
org.w3c.www.protocol.http.HttpManager.CONN_MAX_P, "10" );


Regards,
Dieter Bratko


-----Ursprüngliche Nachricht-----
Von: Taqvi, Syed [IT] [mailto:syed.taqvi@citi.com]
Gesendet: Mittwoch, 19. Dezember 2001 21:32
An: 'Dieter Bratko'; iaik-ssl@iaik.at
Betreff: HTTPS put Issue


Hello All,

I am using Entrust toolkit and using the HttpsURLConnection to set up a ssl
connection to a web server (MS IIS for my test) and trying to PUT a file on
the web server.

My method to get a listing of the files on the web server works fine. I am
also able to download files from the web server without a problem. When I
try to do a PUT, I am able to PUT the file on the server for the first 5
times. Every time, my 6th attempt fails.

Is there some restriction on the number of open HttpsURLConnection by
entrust toolkit?
How do I release the open connection if that is a problem? (disconnect()
does not seem to do it)

Thank you,
Regards,
Syed

The code is attached (I call the upload method multiple times with different
filenames)
*************************************************************

    private void upload(String filename) throws Exception {
        HttpsURLConnection httpsURLConnection = this.getHTTPSConnection(new
URL("https://<IPAddress>/test_iis/" + filename));

        httpsURLConnection.setDoInput(false);
        httpsURLConnection.setDoOutput(true);
        httpsURLConnection.setUseCaches(false);
        httpsURLConnection.setRequestMethod("PUT");

        FileInputStream fileInputStream = new FileInputStream(new
File("c:/docs/brd_mt103.txt"));
        int noOfBytes = fileInputStream.available();
        byte b[] = new byte[noOfBytes];
        fileInputStream.read(b, 0, noOfBytes);
        try {
            fileInputStream.close();
        }
        catch(Exception exception) {
            exception.printStackTrace();
        }

        OutputStream os = httpsURLConnection.getOutputStream();

        BufferedOutputStream bos = new BufferedOutputStream(os);
        bos.write(b);
        bos.flush();
        try {
            bos.close();
            os.close();
        }
        catch(Exception e) {
            System.out.println("Caught exception while writing file");
            e.printStackTrace();
        }
        System.out.println("Response code:
".concat(String.valueOf(httpsURLConnection.getResponseCode())));
        System.out.println("response:
".concat(String.valueOf(httpsURLConnection.getResponseMessage())));
        httpsURLConnection.disconnect();
    }

    private HttpsURLConnection getHTTPSConnection(URL url) throws Exception
{
        HttpsURLConnection httpsURLConnection =
(HttpsURLConnection)url.openConnection();
        String user = "username:password";
        String encoding = (new BASE64Encoder()).encode(user.getBytes());
        httpsURLConnection.setRequestProperty("Authorization", "Basic
".concat(String.valueOf(encoding)));

        SSLContext sslContext = httpsURLConnection.getSSLContext();
        sslContext.setDebugStream(System.out);

        IHTTPSCipherSuiteVerifier httpsCipherSuiteVerifier = new
HTTPSCipherSuiteVerifierImpl();

httpsCipherSuiteVerifier.setCertificateSymmetricKeyLengthInBits(128);
        httpsCipherSuiteVerifier.init();

httpsURLConnection.getSSLContext().setEnabledCipherSuiteList(httpsCipherSuit
eVerifier.getEnabledCipherSuiteList());

        HTTPSChainVerifierImpl httpsChainVerifier = new
HTTPSChainVerifierImpl();
        httpsChainVerifier.setKeyStore(this.keyStore);
        httpsChainVerifier.setKeyStoreFileName(this.keyStoreFileName);
        httpsChainVerifier.setKeyStorePassword(this.keyStoreFilePassword);
        httpsChainVerifier.init();

httpsURLConnection.getSSLContext().setChainVerifier(httpsChainVerifier);

        return httpsURLConnection;
    }



smime.p7s