Bug 792046 - Improve the error message when failing to connect an XMPP/IRC account because of a broken certificate, r=clokep.

This commit is contained in:
Florian Quèze 2012-09-20 18:41:14 +02:00
Родитель a3d50350e9
Коммит 80f3ba5d15
4 изменённых файлов: 19 добавлений и 6 удалений

Просмотреть файл

@ -7,7 +7,6 @@
# disconnected because of an error.
connection.error.lost=Lost connection with server
connection.error.timeOut=Connection timed out
connection.error.certError=Certification error when connecting to server
# LOCALIZATION NOTE (joinChat.*):
# These show up on the join chat menu. An underscore is for the access key.

Просмотреть файл

@ -29,6 +29,7 @@
* onConnectionHeard()
* onConnectionTimedOut()
* onConnectionReset()
* onBadCertificate(AString aNSSErrorMessage)
* onConnectionClosed()
* onDataReceived(data)
* onBinaryDataReceived(ArrayBuffer data, int length)
@ -347,8 +348,16 @@ const Socket = {
this.onConnectionReset();
else if (aStatus == NS_ERROR_NET_TIMEOUT)
this.onConnectionTimedOut();
else
this.onConnectionClosed();
else if (aStatus) {
let nssErrorsService =
Cc["@mozilla.org/nss_errors_service;1"].getService(Ci.nsINSSErrorsService);
if (aStatus <= nssErrorsService.getXPCOMFromNSSError(nssErrorsService.NSS_SEC_ERROR_BASE) &&
aStatus >= nssErrorsService.getXPCOMFromNSSError(nssErrorsService.NSS_SEC_ERROR_LIMIT - 1)) {
this.onBadCertificate(nssErrorsService.getErrorMessage(aStatus));
return;
}
}
this.onConnectionClosed();
},
/*
@ -477,6 +486,8 @@ const Socket = {
onConnectionTimedOut: function() { },
// Called when a socket request's network is reset.
onConnectionReset: function() { },
// Called when the certificate provided by the server didn't satisfy NSS.
onBadCertificate: function(aNSSErrorMessage) { },
// Called when the other end has closed the connection.
onConnectionClosed: function() { },

Просмотреть файл

@ -505,10 +505,10 @@ ircSocket.prototype = {
this._account.gotDisconnected(Ci.prplIAccount.ERROR_NETWORK_ERROR,
_("connection.error.timeOut"));
},
onCertificationError: function(aSocketInfo, aStatus, aTargetSite) {
ERROR("Certification error.");
onBadCertificate: function(aNSSErrorMessage) {
ERROR("bad certificate: " + aNSSErrorMessage);
this._account.gotDisconnected(Ci.prplIAccount.ERROR_CERT_OTHER_ERROR,
_("connection.error.certError"));
aNSSErrorMessage);
},
log: LOG
};

Просмотреть файл

@ -170,6 +170,9 @@ XMPPSession.prototype = {
onConnectionClosed: function() {
this._networkError(_("connection.error.serverClosedConnection"));
},
onBadCertificate: function(aNSSErrorMessage) {
this.onError(Ci.prplIAccount.ERROR_CERT_OTHER_ERROR, aNSSErrorMessage);
},
onConnectionReset: function() {
this._networkError(_("connection.error.resetByPeer"));
},