Detect self-signed cert errors
This commit is contained in:
parent
e7d7f39c95
commit
e732d72550
|
@ -42,6 +42,9 @@
|
||||||
<div class="alert alert-danger" ng-show="errorMessage">
|
<div class="alert alert-danger" ng-show="errorMessage">
|
||||||
<strong>Connection error</strong> The client was unable to connect to the WeeChat relay
|
<strong>Connection error</strong> The client was unable to connect to the WeeChat relay
|
||||||
</div>
|
</div>
|
||||||
|
<div class="alert alert-danger" ng-show="sslError">
|
||||||
|
<strong>Secure connection error</strong> A secure connection with the WeeChat relay could not be initiated. This is most likely because your browser does not trust your relay's certificate. Please read the encryption instructions below!
|
||||||
|
</div>
|
||||||
<div class="panel-group" id="accordion">
|
<div class="panel-group" id="accordion">
|
||||||
<div class="panel">
|
<div class="panel">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
|
|
|
@ -337,14 +337,22 @@ function($rootScope,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
var onclose = function () {
|
var onclose = function (evt) {
|
||||||
/*
|
/*
|
||||||
* Handles websocket disconnection
|
* Handles websocket disconnection
|
||||||
*/
|
*/
|
||||||
$log.info("Disconnected from relay");
|
$log.info("Disconnected from relay");
|
||||||
failCallbacks('disconnection');
|
failCallbacks('disconnection');
|
||||||
$rootScope.connected = false;
|
$rootScope.connected = false;
|
||||||
|
if ($rootScope.waseverconnected) {
|
||||||
$rootScope.$emit('relayDisconnect');
|
$rootScope.$emit('relayDisconnect');
|
||||||
|
} else if (ssl && evt.code === 1006) {
|
||||||
|
// A password error doesn't trigger onerror, but certificate issues do. Check time of last error.
|
||||||
|
if (typeof $rootScope.lastError !== "undefined" && (Date.now() - $rootScope.lastError) < 1000) {
|
||||||
|
// abnormal disconnect by client, most likely ssl error
|
||||||
|
$rootScope.sslError = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
$rootScope.$apply();
|
$rootScope.$apply();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -353,7 +361,8 @@ function($rootScope,
|
||||||
* Handles cases when connection issues come from
|
* Handles cases when connection issues come from
|
||||||
* the relay.
|
* the relay.
|
||||||
*/
|
*/
|
||||||
$log.error("Relay error" + evt.data);
|
$log.error("Relay error", evt);
|
||||||
|
$rootScope.lastError = Date.now();
|
||||||
|
|
||||||
if (evt.type === "error" && this.readyState !== 1) {
|
if (evt.type === "error" && this.readyState !== 1) {
|
||||||
failCallbacks('error');
|
failCallbacks('error');
|
||||||
|
@ -946,6 +955,8 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
||||||
|
|
||||||
$scope.connect = function() {
|
$scope.connect = function() {
|
||||||
$scope.requestNotificationPermission();
|
$scope.requestNotificationPermission();
|
||||||
|
$rootScope.sslError = false;
|
||||||
|
$rootScope.errorMessage = false;
|
||||||
connection.connect($scope.host, $scope.port, $scope.password, $scope.ssl);
|
connection.connect($scope.host, $scope.port, $scope.password, $scope.ssl);
|
||||||
};
|
};
|
||||||
$scope.disconnect = function() {
|
$scope.disconnect = function() {
|
||||||
|
|
Loading…
Reference in New Issue