Cannot download file over https behind firewall ?

I have a program to download files :
public class TestServlet
     public static void main(String args[]){
    Authenticator.setDefault(new AuthImpl());
     if (args.length!=2){
      System.out.println("Proper Usage: java -Dhttp.proxyHost=172.21.32.166 -Dhttp.proxyPort=80 TestServlet RemoteFileURL LocalFileName");
       System.out.println("Usage Example:java -Dhttp.proxyHost=199.67.138.83 -Dhttp.proxyPort=8080 TestServlet https://url.com/csv/file.zip file.zip");
      System.exit(0);
     DataOutputStream out=null;
     FileOutputStream fOut=null;
     try
      trustAllHttpsCertificates();
      String urlStr = args[0];
          HostnameVerifier hv = new HostnameVerifier() {
               public boolean verify(String urlHostName, SSLSession session) {
                    System.out.println("Warning: URL Host: "+urlHostName+" vs. "+session.getPeerHost());
                    return true;
         HttpsURLConnection.setDefaultHostnameVerifier(hv);
          System.out.println("\nConnecting to Website . . . "+urlStr);
          URL url = new URL(urlStr == null ? "https://url/Downloads/WC.csv" : urlStr);
          System.out.println("\nConnecting . . . . ");
          BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
          System.out.println(". . . Connected");
          System.out.print("\nDownloading the file . . . ");
          int buff;
          fOut=new FileOutputStream(args[1]);
          System.out.print(" . .");
          out=new DataOutputStream(fOut);
          System.out.print(" . .");
          while ((buff = in.read()) != -1) {
            fOut.write(buff);
          in.close();
        System.out.println(" . . . Done \n");
      catch (Exception e) {
            e.printStackTrace();
       finally {
          try{
               fOut.flush();
               fOut.close();
               System.exit(0);
           catch(Exception e){
               e.printStackTrace();
    HostnameVerifier hv = new HostnameVerifier()
        public boolean verify(String urlHostName, SSLSession session) {
            //System.out.println("Warning: URL Host: " + urlHostName + " vs. " + session.getPeerHost());
            return true;
    private static void trustAllHttpsCertificates() throws Exception
         //  Create a trust manager that does not validate certificate chains:
        javax.net.ssl.TrustManager[] trustAllCerts =  new javax.net.ssl.TrustManager[1];
        javax.net.ssl.TrustManager tm = new miTM();
        trustAllCerts[0] = tm;
          javax.net.ssl.SSLContext sc = javax.net.ssl.SSLContext.getInstance("SSL");
        sc.init(null, trustAllCerts, null);
        javax.net.ssl.HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
    public static class miTM implements javax.net.ssl.TrustManager, javax.net.ssl.X509TrustManager {
        public java.security.cert.X509Certificate[] getAcceptedIssuers() {
            return null;
        public boolean isServerTrusted(java.security.cert.X509Certificate[] certs) {
            return true;
        public boolean isClientTrusted(java.security.cert.X509Certificate[] certs) {
            return true;
        public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType)
                throws java.security.cert.CertificateException {
            return;
        public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType)
                throws java.security.cert.CertificateException {
            return;
   public static class AuthImpl extends Authenticator {
   protected PasswordAuthentication getPasswordAuthentication() {
      String username = new String("guest");
String password = new String ("guest");
       return new PasswordAuthentication(username, password.toCharArray());
}This program works fine for downloading files, over both http and https from my home. When I run this on my desktop in the office it can download files over http, but cannot download https files.
When I try to download files over https, I get the foll. exception:
java.net.UnknownHostException: www.site.com
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:153)
at java.net.Socket.connect(Socket.java:452)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.<init>(DashoA12275)
at com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl.createSocket(DashoA12275)
at sun.net.www.protocol.https.HttpsClient.doConnect(DashoA12275)
There are 2 differences here, one being that my office desktop sits behind a firewall and there is a proxy in between.
In the office I run the program as :
java -Dhttp.proxyHost -Dhttp.proxyPort TestServlet URL [filename]
eg.:
java -Dhttp.proxyHost=235.67.138.84 -Dhttp.proxyPort=8080 TestServlet https://site.com/portal/Downloads/file.csv file.csv
This url requires authentication, the userid and pwd are hardcoded in the code.
Now, my problem is I cannot understand why this error would come. Is it because of the firewall or because of the proxy ?
Why is it that I can download over http successfully from my office desktop? If the problem is with the firewall or proxy, then even http protocol urls should give the same problem.
Please help.
Vinay
Message was edited by:
vinay_dsouza
Message was edited by:
vinay_dsouza

If you are using HTTPS you should be setting
https.proxyHost
https.proxyPortnot the http.* ones.

Similar Messages

  • Downloading files over HTTPS

    how can i upload files over https
    can you give me some links to web sites that explain this
    thank u

    Hi..
    Have you got the information yet ?
    I need more information for uploading file in https.
    Thanks in advance

  • Header variable: Content Disposition for downloading file over HTTP?

    Hi All,
    I have a general content server question...Is there anyway to pass a parameter or set a setting on the content server to send the file with the header variable content-disposition set so that when a user selects a file within a browser, it doesn't open in place but asks the user whether they want to open or save the document?
    Note - I'm actually using this with ArchiveLink and displaying the link in the Portal but this forum seems the closest I can get to asking this question.
    Regards,
    Matt

    Thanks Athol.
    Although there's quite a bit of configuration options there for displaying files, there doesn't appear to be anything that let's you manipulate the HTTP header variables to set content-disposition.
    Any other ideas?
    Cheers,
    Matt
    ps. If you want to artificially see the behaviour I'm after, within IIS, you can predefine this header variable for the contentserver.dll but this makes every HTTP request act like a file that wants to be downloaded, and it calls every file contentserver.<suffix>. From a user perspective, there's nothing worse than a document opening in place in your window (losing the underlying application), or within another IE window, hence why I'd like it to act like a file download.

  • Downloading Text file over http

    Hi,
    I am trying to display some plain text files over http to the client using a web browser. Everything works fine till the time the file size is small, but for the files of over 1MB the frontend just dies. Probably the display happens only after the complete transfer of the file.
    Does any one have the solution by which the text files can also be downloaded similar to the html files i.e. incrementaly. I have the code of transferring the html file over http as it happens in the explorer. But the same does not seem to work on the plain text files.
    Please help
    Sachin

    I do not have any Remote server written for this. What i am doing is, the directory in which the files are stored is exposed as a virtual directory through a web server(Apache) and then from client i am just placing a http request to open this file.
    So what i can do under this situations to handle the large files.

  • How to set iPad Mini to download files over 50MB?

    I am downloading GarageBand to the iPad Mini and it says I need to connect using Wi-Fi to download files over 50MB, the question is why do I need to connect to a Wi-Fi Station? I have an unlimited LTE connection, what am I paying it for if I need to connect to a Wi-Fi to download files?

    You can try using a MiFi.
    http://en.wikipedia.org/wiki/MiFi

  • Play an audio file over HTTP

    Hello everybody,
    I'm trying to play an audio file over HTTP protocol. The code is the following:
    public class HTTPClientJMF {
         static String url = "http://localhost/audio/Reklam1.wav";
         static String urlFile = "file:///C://tmp/audio/Reklam1.wav";
          * @param args
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              try {
                   DataSource dataS = new URLDataSource(new URL(url));
                   dataS.connect();               
                   Player player = Manager.createPlayer(dataS);
                   player.start();
              } catch (MalformedURLException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (NoPlayerException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
    }Now, if I'm trying to play the file from the local disk (+urlFile+ - using file protocol), everything goes well, but if I'm trying to play the same file from the network (using http protocol) I get the following exception:
    javax.media.NoPlayerException: Cannot find a Player for: javax.media.protocol.URLDataSource@fa9cf
    Can somebody tell me what I'm doing wrong?
    Thank you!

    Ah',..okay. I constructed the DataSource like follows:
    Buffer mediaBuffer = new Buffer();;
              String mediaURL = "http://ares.inescn.pt/video/Reklam1.wav";
              URL url;
              try {
                   url = new URL(mediaURL );
                   InputStream in = url.openStream();
                   BufferedInputStream bufIn = new BufferedInputStream(in);
                   for (;;) {
                        int data = bufIn.read();
                        // Check for EOF
                        if (data == -1)
                             break;
                        else
                             mediaBuffer.setData(data);
                   System.out.println(mediaBuffer.getLength());
                   if (mediaBuffer.getLength() != 0) {
                        DataSource ds = new DataSource();
                        HttpStream[] httpStream = ds.getStreams();
                        System.out.println(httpStream.length);
                        httpStream[0].read(mediaBuffer);
                        ds.connect();
                        ds.start();                         
                        Player player = Manager.createPlayer(ds);
                        player.start();But I still cannot play an audio file (wav format) over the HTTP. Application starts but nothing happened.
    I make the modification like you suggested. (into the DataSource, more exactly for method getStreams()).
    I renamed as well the HttpDatasource into HttpStream.
    Did you actually tried the code? I've been reading the instruction how to test the code but I did not be able to run the example.

  • Hi, I am using HP11 and iPlanet web server. When trying to upload files over HTTP using FORM ENCTYPE="multipart/form-data" that are bigger than a few Kilobytes i get a 408 error. (client timeout).

    Hi, I am using HP11 and iPlanet web server. When trying to upload files over HTTP using FORM ENCTYPE="multipart/form-data" that are bigger than a few Kilobytes i get a 408 error. (client timeout). It is as if the server has decided that the client has timed out during the file upload. The default setting is 30 seconds for AcceptTimeout in the magnus.conf file. This should be ample to get the file across, even increasing this to 2 minutes just produces the same error after 2 minutes. Any help appreciated. Apologies if this is not the correct forum for this, I couldn't see one for iPlanet and Web, many thanks, Kieran.

    Hi,
    You didnt mention which version of IWS. follow these steps.
    (1)Goto Web Server Administration Server, select the server you want to manage.
    (2)Select Preference >> Perfomance Tuning.
    (3)set HTTP Persistent Connection Timeout to your choice (eg 180 sec for three minutes)
    (4) Apply changes and restart the server.
    *Setting the timeout to a lower value, however, may    prevent the transfer of large files as timeout does not refer to the time that the connection has been idle. For example, if you are using a 2400 baud modem, and the request timeout is set to 180 seconds, then the maximum file size that can be transferred before   the connection is closed is 432000 bits (2400 multiplied by 180)
    Regards
    T.Raghulan
    [email protected]

  • Flat file over HTTP or SOAP

    Hey Guys,
    I need to post a Flat file over HTTP (or SOAP), is this possible without developing my own Adapter module?
    I just need to get a Flat file from a FTP server and post to another server via HTTP,since there is no message mapping involved, i developed the scenario without any Integration Repository objects, it is just a pass-through scenario.
    Now i am stuck on the receiver side since i am unable to post Flat file over HTTP.
    Secondly i have Login URL, Logout URL and upload URL from the receiver system, i don't see any place in receiver HTTP adapter to put all these 3 URL's, can i use SOAP adapter to put all these URL anywhere?
    Any help would be appreciated.
    Thanks
    Saif
    Edited by: Saif Manzar on Jan 19, 2010 2:51 AM

    Hey Guys,
    I need to post a Flat file over HTTP (or SOAP), is this possible without developing my own Adapter module?
    I just need to get a Flat file from a FTP server and post to another server via HTTP,since there is no message mapping involved, i developed the scenario without any Integration Repository objects, it is just a pass-through scenario.
    Now i am stuck on the receiver side since i am unable to post Flat file over HTTP.
    Secondly i have Login URL, Logout URL and upload URL from the receiver system, i don't see any place in receiver HTTP adapter to put all these 3 URL's, can i use SOAP adapter to put all these URL anywhere?
    Any help would be appreciated.
    Thanks
    Saif
    Edited by: Saif Manzar on Jan 19, 2010 2:51 AM

  • Retreiving files over http or ftp.

    I was wondering what program I should use to retreive files over http or ftp. Previously I had used wget per my hosting provider's recommendation. It worked when I was ssh logged in to his server (via Mac Terminal). However, when I try using wget on my local Mac it says "command not found".

    Thanks. So if I specify a file name (-o /path/to/file), does the incoming file get renamed to that (and put in that location) or does this specify the directory (-o /path/to/directory) that the incoming file will go to? I wasn't quite clear on that.
    Also, I keep hearing about stdout. What is it exactly? I assumed it was just the Terminal window itself, the alternative being things like | more or | nano or something like that... Or am I totally up the wrong tree?

  • I keep getting error message safari cannot download file.

    Every time I try to download a Mac game from Bigfishgames I get casuarina cannot download file. Also will not allow me to download app. I am a new iPad user.  Am I doing something wrong?

    Correct, Safari can not be used to download files on the iPad. Also a Mac based game will not work on an iPad. Any available Apps for the iPad need to be downloaded from the App Store.

  • With Firefox 4, I cannot download files from the internet. Please help me !

    I cannot download files from the internet (with Firefox 4). I was able to until this upgrade. I am disappointed.
    The site specifically is www.c64g.com/games.php?q=p

    What buttons do you get to click on with this message? What browser are you using (e.g. Safari, Chrome, Internet Explorer...)

  • I cannot drag file over Dock and place into one of more opened windows - i.e. Mail

    I cannot drag file over Dock, i.e. MAIL, wait a second, choose one of 2 windows - MAIL APP or NEW MAIL and place this file into opened New Mail. Normally I will wait until appear 2 windows with Mail app and New mail and choose NewMail and place the file into the new mail. This does not work for now and I have no idea why... Now it will Create only NewMail with this file attachment.
    I tried:
    1. Other Existing USER account
    2. Restart with SHIFT - SafeMode
    3. Reset PRAM
    4. Delete com.apple.dock.plist and restart with default dock.list
    5. It does not work on touchpad on my MacbookAir and with external mouse Logitech MX Revolution too
    6. I have no plugins in MAIL APP

    Create an album and drag them into the album. Then you can easily select all of them in the album and email.
    OT

  • Cannot download files via Bluetooth since upgrading to Yosemite

    I cannot download files, E.G. photos and spreadsheets, from my Windows phone to my MacBook Pro Retina since upgrading to OS 10.10 Yosemite.
    I can send files from the MacBook Pro to the Windows phone.
    Tried resetting PRAM, no luck
    Tried unpairing and repairing all devices, no luck
    Tried dumping "bluetooth.plist", no luck
    Tried cold start & Resart after each, no luck
    Devices are paired. Bluetooth Sharing is on.
    Help!

    PROBLEM SOLVED:
    Go to "System Preferences" - "Sharing" - "Bluetooth Sharing" - "Folder for selected items:", and select a folder."
    No folder is selected.
    Prior to the upgrade the Folder had been set to "Downloads", so I reset it to "Downloads" and it now works.
    Praise the Lord!!

  • Cannot download files in IE

    I cannot download files similar to what is described in this question.... <Microsoft blocked the link>
    I am using Win 7 and IE 11.  When I try to download files, like WinRAR <Microsoft blocked the link> or Firefox <Microsoft blocked the link>.  Files get renamed.  For the winrar example the file gets renamed to "dl_". 
    Most of the time only the dot before the exe gets renamed but as you can see with the WinRAR example, that is not always the case.
    Executables are not the only culprit.   I think the problem happens when the download is initiated by the website, versus right clicking on an img and downloading.  I use TaxAct and the problem happens when trying to download non-executable
    files from there.  I can only assume that the files are pdf's but the rename of the file prevents me from knowing what type of files they are.
    thanks

    Hi,
    Do you mean that you can successfully download these files but these files are not useful or broken? Did you see any message prompted? When did this issue happen? Did you make any changes before?
    What is the security level of your IE? Go to Tools\Internet Options\Security\Interbet or trusted site, see the security level, set it to the default level.
    Clear the history of IE,  run a security scan to make sure the safety of your system, change the location of the downloads, test the result again.
    Yolanda Zhu
    TechNet Community Support

  • Hi I am trying to download the family tree maker that i purchased by email onto my ipad however I keep getting the same thing SAFARI CANNOT DOWNLOAD FILE can anyone help me solve this problem thanks.....bebe

    Hi i am i have any ipad and i am trying to download family tree maker that i purchased online, but all that keeps co ing up is safari cannot download file can anyone help me .....bebe

    I think you are trying to install a computer application to use on an iPad. You can't. They are incompatible pieces of hardware. If you want Family Tree Maker for your iPad, then you need to get that version, if it exists, from the iTunes Store. That download can't be done via Safari.

Maybe you are looking for

  • A question about class and interface? please help me!

    the following is program: interface A{ public class B implements A{ public static void main(String [] args){ A a = new B(); System.out.println(a.toString()); }i want to ask a question, the method toString() is not belong to interface A, why a can cal

  • Error in Client Proxy creation

    Hi , In SPROXY txn , When iam asked for prefix, I have given 'z' and have used Local object . Then i have saved and activated the proxy created. But when i open the proxy class created , I couldn't see the EXECUTE_ASYNCHRONOUS method  but there is so

  • After turning back depreciation SAP is extending the UL of the assets

    Dear Experts, I have a situation where I had the assets shutdown for several periods and changed depreciation key to zero because my system is using weighting periods and days method.  Now need to turn depreciation back For the situation when I turn

  • Localhost and http request dilemma!

    Right I have 2 web app servers, one running on serverA from machine1 and one running on serverB from machine2. OK, what I want to be able to do is from machine1 open a browser to a webpage running on serverB/page1.jsp. From page1.jsp I want to make a

  • My Power Mac G4 shut down instead of sleeping

    Is there anyone out there having this problem..? When I put my PM to sleep it shut down instead. If I try to restart it right away it starts booting but fails after a couple of seconds and shut down again. If I wait for a longer while it starts like