3

I have created some HTTPS-Server with a self signed certificate with this CN=localhost. But when I'm starting the Client, it tells me some Bind-Exception:

socket::connect fails with error code = 10049

I created some new certificate with CN=hostname, which I found out (and which is the computer name) with following line:

hostname = InetAddress.getLocalHost());

But this way is not a practical for me. I want to create one certificate with some URL like example.com and want to use this certificate more than one time. So i had following idea: I adding some url to /etc/hosts-file with this:

127.0.0.1      example.com

And then I'm using the URL example.com.

Is there any way to change InetAddress.getLocalhost? Or is there a possibility to use some customer ip-address order hostname?

I have used:

InetSocketAddress address = new InetSocketAddress("test.com",9999);

to create a customer address, but this not resolved the Bind-Exception.

Do someone have any ideas?

2

1 Answer 1

0

When hostname to hostname mapping is not possible, let us create certificate with IP Address and later map n number of hostnames to same IP Address.

Create the certificate with CN=127.0.0.1 or CN=<LOCAL_IP_ADDRESS> and then resolve it to example.com through hosts file and then try to use InetSocketAddress address = new InetSocketAddress("example.com",9999);

3
  • Hello! Thx for your response! I have created a new self signed certificate and imported it to my existing keystore. Now i have got this exception: Exception thrown: javax.microedition.pki.CertificateException:Certificate does not contain the correct site name localhost vs test.com I dont understand this exception. Because i have imported both! The certificate for localhost and test.com. :-(
    – Mira Mira
    Jul 25, 2016 at 14:18
  • How many entries do you have in the certificate? Could you try with a fresh certificate file with CN=127.0.0.1? Jul 25, 2016 at 14:27
  • What do you mean with "How many entries do you have in certificate?" I created a fresh certificate with openssl and imported this to my keystore. But this not resolved my problem. With my browser as client i am able to reach my server. But with my client, which is a java application i am getting know this error: IOException occured socket::connect fails with error code = 10051 when I am trying to reach the hostname, which i get like written above. I'm trying to resolve https://hostname:443/
    – Mira Mira
    Jul 26, 2016 at 11:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.