Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7783477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:51:02+00:00 2026-06-01T19:51:02+00:00

I want to download a file from the server which is using the secured

  • 0

I want to download a file from the server which is using the secured connection protocol HTTPS. I could do it in the normal server, But, how I can do it using the HTTPS. If anyone have used the sample API, please help me to find the useful resources.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T19:51:04+00:00Added an answer on June 1, 2026 at 7:51 pm

    Access an HTTPS url with Java is the same then access an HTTP url. You can always use the

    URL url = new URL("https://hostname:port/file.txt");
    URLConnection connection = url.openConnection();
    InputStream is = connection.getInputStream();
    // .. then download the file
    

    But, you can have some problem when the server’s certificate chain cannot be validated.
    So you may need to disable the validation of certificates for testing purposes and trust all certificates.

    To do that write:

    // Create a new trust manager that trust all certificates
    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) {
            }
        }
    };
    
    // Activate the new trust manager
    try {
        SSLContext sc = SSLContext.getInstance("SSL");
        sc.init(null, trustAllCerts, new java.security.SecureRandom());
        HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
    } catch (Exception e) {
    }
    
    // And as before now you can use URL and URLConnection
    URL url = new URL("https://hostname:port/file.txt");
    URLConnection connection = url.openConnection();
    InputStream is = connection.getInputStream();
    // .. then download the file
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to download a PDF file from a SQL Server database which is
I have a large file I want to download from a server I have
I want to download a huge file from an ftp server in chunks of
I want to download a file from another server with save as dialog box...
I am developing an web application which can upload/download a file from client to
I want to download a file from server to a local host. i have
I want to download a wav file from a web service, cache it on
I want to download an mp3 File from a Link on the Phone(Isolated Storage)
I got a WPF application and I want to download a file. I'm using
I want to download a .zip file which is available at URL http://www.nseindia.com/content/equities/cmbhav.htm by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.