CBSConnection.getSecurityState Member
Gets an array containing information about the security of the connection.
Syntax
object.getSecurityState();
Returns
An array with at least one item, containing a value from the |STATE_IS_*| enumeration at the top of this file. Iff this is STATE_IS_SECURE, the array has a second item indicating the level of security - a value from the |STATE_SECURE_*| enumeration.
Remarks
STATE_IS_BROKEN is returned if any errors occur and STATE_IS_INSECURE is returned for disconnected sockets.
See Also
Source Code
function bc_getsecuritystate()
{
if (!this.isConnected || !this._transport.securityInfo)
return [STATE_IS_INSECURE];
try
{
var sslSp = Components.interfaces.nsISSLStatusProvider;
var sslStatus = Components.interfaces.nsISSLStatus;
// Get the actual SSL Status
sslSp = this._transport.securityInfo.QueryInterface(sslSp);
sslStatus = sslSp.SSLStatus.QueryInterface(sslStatus);
// Store appropriate status
if (!("keyLength" in sslStatus) || !sslStatus.keyLength)
return [STATE_IS_BROKEN];
else if (sslStatus.keyLength >= 90)
return [STATE_IS_SECURE, STATE_SECURE_HIGH];
else
return [STATE_IS_SECURE, STATE_SECURE_LOW];
}
catch (ex)
{
// Something goes wrong -> broken security icon
dd("Exception getting certificate for connection: " + ex.message);
return [STATE_IS_BROKEN];
}
}