Marcel Panse
Marcel Panse

Reputation: 642

How to check if url exists over https in java

I know how to check if a url exists in using, see following posts.

Check if file exists on remote server using its URL

How to check if a URL exists or returns 404 with Java?

The problem is if a ssl https url exists, i tried all suggestions in the above threads, and while they work fine on normal http urls, none of them work on a https file.

Is it not possible?

Suggestions?

Upvotes: 0

Views: 3355

Answers (1)

Stephen C
Stephen C

Reputation: 718718

The normal methods that work with "http:" URLs should also work with "https:" URLs. If they don't, then the probable cause is not the code but something else:

  • The URLs might use a SSL certificate that is not acceptable to Java. It might be self-signed, it might use a root certificate that your JVM's certificate store doesn't include. It might be the wrong certificate for the site.

  • It might be a problem with your JVM's proxy configurations. (You can't proxy HTTPS).

  • The remote site might simply not be listening for HTTPS requests.

  • The remote site might filter HTTPS requests based on header fields; e.g. the agent header.

To help us help you find the problem:

  • tell us what URL you are trying to access,
  • tell us if the URL works for you using a web browser,
  • if there are exceptions, show us the stacktraces.

Upvotes: 1

Related Questions