Android websocket client SSL error when connecting to server running multiple SSL enabled web applications
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I am working on the Android client implementation that connects via websocket to a server. I've just enabled HTTPS on the server instance and now I am receiving this issue:
W/System.err: com.neovisionaries.ws.client.HostnameUnverifiedException: The certificate of the peer (CN=otherdomain.com) does not match the expected hostname (domain.com)
at com.neovisionaries.ws.client.SocketConnector.verifyHostname(SocketConnector.java:171)
at com.neovisionaries.ws.client.SocketConnector.doConnect(SocketConnector.java:126)
at com.neovisionaries.ws.client.SocketConnector.connect(SocketConnector.java:83)
at com.neovisionaries.ws.client.WebSocket.connect(WebSocket.java:2152)
at com.neovisionaries.ws.client.ConnectThread.runMain(ConnectThread.java:32)
at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45)
It seems that the websocket client is finding mismatched server host names.
Some other related info:
otherdomain.com
is a different one of our URLs. It is pointed to separate instance of the same web application running on the same server as domain.com
which is the app I am currently working on.
My code is logging the URL that it is connecting to and I can see that it is correctly referencing domain.com
:
connecting to: wss://domain.com?session_key=TheCorrectSessionKey
As noted otherdomain.com
is another instance of the same web application. That instance already previously had HTTPS enabled and everything is working properly with that instance. The same client code I am using now is able to connect successfully to this instance.
The same web application has a front end page that also connects to the websocket via wss://. This is working properly in both Chrome and Firefox browsers for domain.com
, as far as I can tell the only client having issues is the Android client, and it's only the domain.com
variant of the app having issues, the otherdomain.com
one seems to be working fine.
I found this issue opened on the library I am using for websockets. But I'm not 100% sure if my problem is related to it, but it may be. In particular someone states:
Not being able to connect to a WebSocket-enabled server domain unless it is also configured to be the default server on the website.
I assume only one site can be default, and perhaps otherdomain.com
got set to default since it was completed first. This is all a bit over my head though to be honest, I'm not sure if this is relavent or not.
android django nginx websocket daphne
add a comment |
I am working on the Android client implementation that connects via websocket to a server. I've just enabled HTTPS on the server instance and now I am receiving this issue:
W/System.err: com.neovisionaries.ws.client.HostnameUnverifiedException: The certificate of the peer (CN=otherdomain.com) does not match the expected hostname (domain.com)
at com.neovisionaries.ws.client.SocketConnector.verifyHostname(SocketConnector.java:171)
at com.neovisionaries.ws.client.SocketConnector.doConnect(SocketConnector.java:126)
at com.neovisionaries.ws.client.SocketConnector.connect(SocketConnector.java:83)
at com.neovisionaries.ws.client.WebSocket.connect(WebSocket.java:2152)
at com.neovisionaries.ws.client.ConnectThread.runMain(ConnectThread.java:32)
at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45)
It seems that the websocket client is finding mismatched server host names.
Some other related info:
otherdomain.com
is a different one of our URLs. It is pointed to separate instance of the same web application running on the same server as domain.com
which is the app I am currently working on.
My code is logging the URL that it is connecting to and I can see that it is correctly referencing domain.com
:
connecting to: wss://domain.com?session_key=TheCorrectSessionKey
As noted otherdomain.com
is another instance of the same web application. That instance already previously had HTTPS enabled and everything is working properly with that instance. The same client code I am using now is able to connect successfully to this instance.
The same web application has a front end page that also connects to the websocket via wss://. This is working properly in both Chrome and Firefox browsers for domain.com
, as far as I can tell the only client having issues is the Android client, and it's only the domain.com
variant of the app having issues, the otherdomain.com
one seems to be working fine.
I found this issue opened on the library I am using for websockets. But I'm not 100% sure if my problem is related to it, but it may be. In particular someone states:
Not being able to connect to a WebSocket-enabled server domain unless it is also configured to be the default server on the website.
I assume only one site can be default, and perhaps otherdomain.com
got set to default since it was completed first. This is all a bit over my head though to be honest, I'm not sure if this is relavent or not.
android django nginx websocket daphne
I think you've correctly identified SNI as the problem! Did you try the solution here?
– greeble31
Nov 26 '18 at 22:41
@greeble31 I'm not sure how to try what is linked in that post. I'm not using an SSLSocket object or anything in my code. I've usedWebSocketFactory.createSocket()
to open my connection.
– FoamyGuy
Nov 26 '18 at 23:01
@greeble31 I did see further down in this discussionNone of this changes the fact that the library did not check the hostname in versions prior to 2.1
. I tried changing the versions of my websocket client down to2.0
and now my connection is working successfully. However I suspect downgrading is not an ideal solution.
– FoamyGuy
Nov 26 '18 at 23:08
"and now my connection is working successfully" <-- Hmm. That really shouldn't have happened... I don't know too much about nv-websocket-client, so I can't help you there. The statement about hostname checking has more to do with good security practices on the client, rather than connectivity issues. Of course you should be concerned with both, but if your library has big security holes, may be time to check out a different library...
– greeble31
Nov 26 '18 at 23:24
add a comment |
I am working on the Android client implementation that connects via websocket to a server. I've just enabled HTTPS on the server instance and now I am receiving this issue:
W/System.err: com.neovisionaries.ws.client.HostnameUnverifiedException: The certificate of the peer (CN=otherdomain.com) does not match the expected hostname (domain.com)
at com.neovisionaries.ws.client.SocketConnector.verifyHostname(SocketConnector.java:171)
at com.neovisionaries.ws.client.SocketConnector.doConnect(SocketConnector.java:126)
at com.neovisionaries.ws.client.SocketConnector.connect(SocketConnector.java:83)
at com.neovisionaries.ws.client.WebSocket.connect(WebSocket.java:2152)
at com.neovisionaries.ws.client.ConnectThread.runMain(ConnectThread.java:32)
at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45)
It seems that the websocket client is finding mismatched server host names.
Some other related info:
otherdomain.com
is a different one of our URLs. It is pointed to separate instance of the same web application running on the same server as domain.com
which is the app I am currently working on.
My code is logging the URL that it is connecting to and I can see that it is correctly referencing domain.com
:
connecting to: wss://domain.com?session_key=TheCorrectSessionKey
As noted otherdomain.com
is another instance of the same web application. That instance already previously had HTTPS enabled and everything is working properly with that instance. The same client code I am using now is able to connect successfully to this instance.
The same web application has a front end page that also connects to the websocket via wss://. This is working properly in both Chrome and Firefox browsers for domain.com
, as far as I can tell the only client having issues is the Android client, and it's only the domain.com
variant of the app having issues, the otherdomain.com
one seems to be working fine.
I found this issue opened on the library I am using for websockets. But I'm not 100% sure if my problem is related to it, but it may be. In particular someone states:
Not being able to connect to a WebSocket-enabled server domain unless it is also configured to be the default server on the website.
I assume only one site can be default, and perhaps otherdomain.com
got set to default since it was completed first. This is all a bit over my head though to be honest, I'm not sure if this is relavent or not.
android django nginx websocket daphne
I am working on the Android client implementation that connects via websocket to a server. I've just enabled HTTPS on the server instance and now I am receiving this issue:
W/System.err: com.neovisionaries.ws.client.HostnameUnverifiedException: The certificate of the peer (CN=otherdomain.com) does not match the expected hostname (domain.com)
at com.neovisionaries.ws.client.SocketConnector.verifyHostname(SocketConnector.java:171)
at com.neovisionaries.ws.client.SocketConnector.doConnect(SocketConnector.java:126)
at com.neovisionaries.ws.client.SocketConnector.connect(SocketConnector.java:83)
at com.neovisionaries.ws.client.WebSocket.connect(WebSocket.java:2152)
at com.neovisionaries.ws.client.ConnectThread.runMain(ConnectThread.java:32)
at com.neovisionaries.ws.client.WebSocketThread.run(WebSocketThread.java:45)
It seems that the websocket client is finding mismatched server host names.
Some other related info:
otherdomain.com
is a different one of our URLs. It is pointed to separate instance of the same web application running on the same server as domain.com
which is the app I am currently working on.
My code is logging the URL that it is connecting to and I can see that it is correctly referencing domain.com
:
connecting to: wss://domain.com?session_key=TheCorrectSessionKey
As noted otherdomain.com
is another instance of the same web application. That instance already previously had HTTPS enabled and everything is working properly with that instance. The same client code I am using now is able to connect successfully to this instance.
The same web application has a front end page that also connects to the websocket via wss://. This is working properly in both Chrome and Firefox browsers for domain.com
, as far as I can tell the only client having issues is the Android client, and it's only the domain.com
variant of the app having issues, the otherdomain.com
one seems to be working fine.
I found this issue opened on the library I am using for websockets. But I'm not 100% sure if my problem is related to it, but it may be. In particular someone states:
Not being able to connect to a WebSocket-enabled server domain unless it is also configured to be the default server on the website.
I assume only one site can be default, and perhaps otherdomain.com
got set to default since it was completed first. This is all a bit over my head though to be honest, I'm not sure if this is relavent or not.
android django nginx websocket daphne
android django nginx websocket daphne
asked Nov 26 '18 at 21:36
FoamyGuyFoamyGuy
40.4k15108143
40.4k15108143
I think you've correctly identified SNI as the problem! Did you try the solution here?
– greeble31
Nov 26 '18 at 22:41
@greeble31 I'm not sure how to try what is linked in that post. I'm not using an SSLSocket object or anything in my code. I've usedWebSocketFactory.createSocket()
to open my connection.
– FoamyGuy
Nov 26 '18 at 23:01
@greeble31 I did see further down in this discussionNone of this changes the fact that the library did not check the hostname in versions prior to 2.1
. I tried changing the versions of my websocket client down to2.0
and now my connection is working successfully. However I suspect downgrading is not an ideal solution.
– FoamyGuy
Nov 26 '18 at 23:08
"and now my connection is working successfully" <-- Hmm. That really shouldn't have happened... I don't know too much about nv-websocket-client, so I can't help you there. The statement about hostname checking has more to do with good security practices on the client, rather than connectivity issues. Of course you should be concerned with both, but if your library has big security holes, may be time to check out a different library...
– greeble31
Nov 26 '18 at 23:24
add a comment |
I think you've correctly identified SNI as the problem! Did you try the solution here?
– greeble31
Nov 26 '18 at 22:41
@greeble31 I'm not sure how to try what is linked in that post. I'm not using an SSLSocket object or anything in my code. I've usedWebSocketFactory.createSocket()
to open my connection.
– FoamyGuy
Nov 26 '18 at 23:01
@greeble31 I did see further down in this discussionNone of this changes the fact that the library did not check the hostname in versions prior to 2.1
. I tried changing the versions of my websocket client down to2.0
and now my connection is working successfully. However I suspect downgrading is not an ideal solution.
– FoamyGuy
Nov 26 '18 at 23:08
"and now my connection is working successfully" <-- Hmm. That really shouldn't have happened... I don't know too much about nv-websocket-client, so I can't help you there. The statement about hostname checking has more to do with good security practices on the client, rather than connectivity issues. Of course you should be concerned with both, but if your library has big security holes, may be time to check out a different library...
– greeble31
Nov 26 '18 at 23:24
I think you've correctly identified SNI as the problem! Did you try the solution here?
– greeble31
Nov 26 '18 at 22:41
I think you've correctly identified SNI as the problem! Did you try the solution here?
– greeble31
Nov 26 '18 at 22:41
@greeble31 I'm not sure how to try what is linked in that post. I'm not using an SSLSocket object or anything in my code. I've used
WebSocketFactory.createSocket()
to open my connection.– FoamyGuy
Nov 26 '18 at 23:01
@greeble31 I'm not sure how to try what is linked in that post. I'm not using an SSLSocket object or anything in my code. I've used
WebSocketFactory.createSocket()
to open my connection.– FoamyGuy
Nov 26 '18 at 23:01
@greeble31 I did see further down in this discussion
None of this changes the fact that the library did not check the hostname in versions prior to 2.1
. I tried changing the versions of my websocket client down to 2.0
and now my connection is working successfully. However I suspect downgrading is not an ideal solution.– FoamyGuy
Nov 26 '18 at 23:08
@greeble31 I did see further down in this discussion
None of this changes the fact that the library did not check the hostname in versions prior to 2.1
. I tried changing the versions of my websocket client down to 2.0
and now my connection is working successfully. However I suspect downgrading is not an ideal solution.– FoamyGuy
Nov 26 '18 at 23:08
"and now my connection is working successfully" <-- Hmm. That really shouldn't have happened... I don't know too much about nv-websocket-client, so I can't help you there. The statement about hostname checking has more to do with good security practices on the client, rather than connectivity issues. Of course you should be concerned with both, but if your library has big security holes, may be time to check out a different library...
– greeble31
Nov 26 '18 at 23:24
"and now my connection is working successfully" <-- Hmm. That really shouldn't have happened... I don't know too much about nv-websocket-client, so I can't help you there. The statement about hostname checking has more to do with good security practices on the client, rather than connectivity issues. Of course you should be concerned with both, but if your library has big security holes, may be time to check out a different library...
– greeble31
Nov 26 '18 at 23:24
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53489438%2fandroid-websocket-client-ssl-error-when-connecting-to-server-running-multiple-ss%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53489438%2fandroid-websocket-client-ssl-error-when-connecting-to-server-running-multiple-ss%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I think you've correctly identified SNI as the problem! Did you try the solution here?
– greeble31
Nov 26 '18 at 22:41
@greeble31 I'm not sure how to try what is linked in that post. I'm not using an SSLSocket object or anything in my code. I've used
WebSocketFactory.createSocket()
to open my connection.– FoamyGuy
Nov 26 '18 at 23:01
@greeble31 I did see further down in this discussion
None of this changes the fact that the library did not check the hostname in versions prior to 2.1
. I tried changing the versions of my websocket client down to2.0
and now my connection is working successfully. However I suspect downgrading is not an ideal solution.– FoamyGuy
Nov 26 '18 at 23:08
"and now my connection is working successfully" <-- Hmm. That really shouldn't have happened... I don't know too much about nv-websocket-client, so I can't help you there. The statement about hostname checking has more to do with good security practices on the client, rather than connectivity issues. Of course you should be concerned with both, but if your library has big security holes, may be time to check out a different library...
– greeble31
Nov 26 '18 at 23:24