• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

Https connection using a hostname not a url.

 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i want to establish a https connection for which i will provide a hostname portno username password etc.
most of the online code snippets are mostly using SSl or TSL inorder to establish a connection if not using a url and establishing the connection by appending the encrypted username and password with it to establish a connection.

i have a scenario where i use a hostname portno(optional) username password and to establish the connection. can any one guide me how to do this.
 
Rancher
Posts: 43024
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you tried new URLConnection("https://www.server.com:1234")? It'll probably work out of the box. Passing the username/password has nothing to do with HTTP vs. HTTPS, so you need to do that independently of making the connection.
 
saipraneeth nallapareddy
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the reply, can you explain a bit clear

Ulf Dittmer wrote:Have you tried new URLConnection("https://www.server.com:1234")?


i used SSLServerSocketFactory, SSLServerSocket & SSLSocket on the server side
SSLSocketFactory, SSLSocket on the client for a basic connection.

but my main question is to avoid a url and ssl(i guess cannot be ignored) ,completly use https connection to perform the communication, but

Ulf Dittmer wrote:URLConnection("https://www.server.com:1234")?


will answer my problem?
but if you have asked me whether https connection worked using the url then my answer is yes.
correct me if i am wrong in understanding what you have asked and i guess i made my requirement clear, please guide me.
 
Sheriff
Posts: 22256
119
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:Have you tried new URLConnection("https://www.server.com:1234")? It'll probably work out of the box.


Not like this; URLConnection is abstract. Using java.net.URL it should work though:

Saipraneeth, a URL and host name do not need to be mutually exclusive. http://www.javaranch.com/ is a URL that has a host name; http://127.0.0.1/ is a URL that has an IP address.
 
saipraneeth nallapareddy
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Prime wrote: a URL and host name do not need to be mutually exclusive. http://www.javaranch.com/ is a URL that has a host name; http://127.0.0.1/ is a URL that has an IP address.


upto my knowledge the IP-address for machine in order to make it more simple to use undergoes DNS configuration which will get www.somename.com, correct me if i am wrong.
so here can say from your explanation that i can use the machine name that i am using as the hostname for the sake of the connection(secure)?
 
Rob Spoor
Sheriff
Posts: 22256
119
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's the other way around - www.somename.com will be translated into an IP address. So if you use a host name in the URL, this is somewhere in the background (probably even outside your Java program) translated into an IP address, and a request is made to this IP address on the port you specified with the HTTPS protocol. So what makes your connection secure is not the host name, IP address or port, but the protocol.
 
saipraneeth nallapareddy
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks RobPrime it did worked.
 
Rob Spoor
Sheriff
Posts: 22256
119
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome.
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic