|
|
ec4b96 |
--- ./esc/src/lib/NssHttpClient/engine.h.fix6 2009-06-19 16:07:39.000000000 -0700
|
|
|
ec4b96 |
+++ ./esc/src/lib/NssHttpClient/engine.h 2009-06-19 16:07:44.000000000 -0700
|
|
|
ec4b96 |
@@ -22,9 +22,17 @@
|
|
|
ec4b96 |
#include "response.h"
|
|
|
ec4b96 |
#include "request.h"
|
|
|
ec4b96 |
|
|
|
ec4b96 |
+struct BadCertData {
|
|
|
ec4b96 |
+ PRErrorCode error;
|
|
|
ec4b96 |
+ PRInt32 port;
|
|
|
ec4b96 |
+};
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+typedef struct BadCertData BadCertData;
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
class __EXPORT Engine {
|
|
|
ec4b96 |
public:
|
|
|
ec4b96 |
- Engine() {};
|
|
|
ec4b96 |
+ Engine() { _certData = NULL; _sock=NULL;};
|
|
|
ec4b96 |
~Engine() {};
|
|
|
ec4b96 |
|
|
|
ec4b96 |
PRFileDesc *_doConnect(PRNetAddr *addr, PRBool SSLOn = PR_FALSE,
|
|
|
ec4b96 |
@@ -37,7 +45,8 @@
|
|
|
ec4b96 |
static PRIntervalTime globaltimeout;
|
|
|
ec4b96 |
|
|
|
ec4b96 |
PRFileDesc *_sock;
|
|
|
ec4b96 |
-
|
|
|
ec4b96 |
+ BadCertData *_certData;
|
|
|
ec4b96 |
+ BadCertData *getBadCertData() { return _certData;}
|
|
|
ec4b96 |
PRFileDesc *getSocket() { return _sock;}
|
|
|
ec4b96 |
|
|
|
ec4b96 |
bool connectionClosed ;
|
|
|
ec4b96 |
--- ./esc/src/lib/NssHttpClient/engine.cpp.fix6 2009-06-19 16:07:12.000000000 -0700
|
|
|
ec4b96 |
+++ ./esc/src/lib/NssHttpClient/engine.cpp 2009-06-19 16:07:29.000000000 -0700
|
|
|
ec4b96 |
@@ -16,6 +16,8 @@
|
|
|
ec4b96 |
* All rights reserved.
|
|
|
ec4b96 |
* END COPYRIGHT BLOCK **/
|
|
|
ec4b96 |
|
|
|
ec4b96 |
+#define FORCE_PR_LOG 1
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
#include <nspr.h>
|
|
|
ec4b96 |
#include "sslproto.h"
|
|
|
ec4b96 |
#include <prerror.h>
|
|
|
ec4b96 |
@@ -27,7 +29,7 @@
|
|
|
ec4b96 |
#include "certt.h"
|
|
|
ec4b96 |
#include "sslerr.h"
|
|
|
ec4b96 |
#include "secerr.h"
|
|
|
ec4b96 |
-
|
|
|
ec4b96 |
+#include "CoolKey.h"
|
|
|
ec4b96 |
#include "engine.h"
|
|
|
ec4b96 |
#include "http.h"
|
|
|
ec4b96 |
|
|
|
ec4b96 |
@@ -39,6 +41,9 @@
|
|
|
ec4b96 |
int cipherCount = 0;
|
|
|
ec4b96 |
int _doVerifyServerCert = 1;
|
|
|
ec4b96 |
|
|
|
ec4b96 |
+PRLogModuleInfo *httpEngineLog = PR_NewLogModule("coolKeyHttpEngine");
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
PRIntervalTime Engine::globaltimeout = PR_TicksPerSecond()*30;
|
|
|
ec4b96 |
|
|
|
ec4b96 |
/**
|
|
|
ec4b96 |
@@ -56,13 +61,26 @@
|
|
|
ec4b96 |
SECStatus secStatus = SECFailure;
|
|
|
ec4b96 |
PRErrorCode err;
|
|
|
ec4b96 |
|
|
|
ec4b96 |
+ char tBuff[56];
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ PR_LOG(httpEngineLog, PR_LOG_DEBUG,
|
|
|
ec4b96 |
+ ("%s myBadCertHandler enter. \n",GetTStamp(tBuff,56)));
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
/* log invalid cert here */
|
|
|
ec4b96 |
|
|
|
ec4b96 |
if ( !arg ) {
|
|
|
ec4b96 |
return secStatus;
|
|
|
ec4b96 |
}
|
|
|
ec4b96 |
|
|
|
ec4b96 |
- *(PRErrorCode *)arg = err = PORT_GetError();
|
|
|
ec4b96 |
+ err = PORT_GetError();
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ BadCertData *data = (BadCertData *) arg;
|
|
|
ec4b96 |
+ if(data) {
|
|
|
ec4b96 |
+ data->error = err;
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ PR_LOG(httpEngineLog, PR_LOG_DEBUG,
|
|
|
ec4b96 |
+ ("%s myBadCertHandler err: %d . \n",GetTStamp(tBuff,56),err));
|
|
|
ec4b96 |
|
|
|
ec4b96 |
/* If any of the cases in the switch are met, then we will proceed */
|
|
|
ec4b96 |
/* with the processing of the request anyway. Otherwise, the default */
|
|
|
ec4b96 |
@@ -91,6 +109,10 @@
|
|
|
ec4b96 |
break;
|
|
|
ec4b96 |
}
|
|
|
ec4b96 |
|
|
|
ec4b96 |
+ PR_LOG(httpEngineLog, PR_LOG_DEBUG,
|
|
|
ec4b96 |
+ ("%s myBadCertHandler status: %d . \n",GetTStamp(tBuff,56),secStatus));
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
return secStatus;
|
|
|
ec4b96 |
}
|
|
|
ec4b96 |
|
|
|
ec4b96 |
@@ -416,7 +438,6 @@
|
|
|
ec4b96 |
return;
|
|
|
ec4b96 |
}
|
|
|
ec4b96 |
|
|
|
ec4b96 |
-
|
|
|
ec4b96 |
void Engine::CloseConnection()
|
|
|
ec4b96 |
{
|
|
|
ec4b96 |
connectionClosed = true;
|
|
|
ec4b96 |
@@ -426,7 +447,14 @@
|
|
|
ec4b96 |
PR_Close(_sock);
|
|
|
ec4b96 |
_sock = NULL;
|
|
|
ec4b96 |
}
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ if(_certData)
|
|
|
ec4b96 |
+ {
|
|
|
ec4b96 |
+ delete _certData;
|
|
|
ec4b96 |
+ _certData = NULL;
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
}
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
/**
|
|
|
ec4b96 |
* Returns a file descriptor for I/O if the HTTP connection is successful
|
|
|
ec4b96 |
* @param addr PRnetAddr structure which points to the server to connect to
|
|
|
ec4b96 |
@@ -442,21 +470,19 @@
|
|
|
ec4b96 |
PRFileDesc *tcpsock = NULL;
|
|
|
ec4b96 |
PRFileDesc *sock = NULL;
|
|
|
ec4b96 |
connectionClosed = false;
|
|
|
ec4b96 |
+ _certData = new BadCertData();
|
|
|
ec4b96 |
|
|
|
ec4b96 |
tcpsock = PR_OpenTCPSocket(addr->raw.family);
|
|
|
ec4b96 |
-
|
|
|
ec4b96 |
|
|
|
ec4b96 |
if (!tcpsock) {
|
|
|
ec4b96 |
-
|
|
|
ec4b96 |
return NULL;
|
|
|
ec4b96 |
}
|
|
|
ec4b96 |
|
|
|
ec4b96 |
nodelay(tcpsock);
|
|
|
ec4b96 |
|
|
|
ec4b96 |
if (PR_TRUE == SSLOn) {
|
|
|
ec4b96 |
- sock=SSL_ImportFD(NULL, tcpsock);
|
|
|
ec4b96 |
-
|
|
|
ec4b96 |
|
|
|
ec4b96 |
+ sock=SSL_ImportFD(NULL, tcpsock);
|
|
|
ec4b96 |
if (!sock) {
|
|
|
ec4b96 |
//xxx log
|
|
|
ec4b96 |
if( tcpsock != NULL ) {
|
|
|
ec4b96 |
@@ -516,9 +542,23 @@
|
|
|
ec4b96 |
|
|
|
ec4b96 |
PRErrorCode errCode = 0;
|
|
|
ec4b96 |
|
|
|
ec4b96 |
- rv = SSL_BadCertHook( sock,
|
|
|
ec4b96 |
+ if(_certData) {
|
|
|
ec4b96 |
+ _certData->error = errCode;
|
|
|
ec4b96 |
+ _certData->port = PR_ntohs(PR_NetAddrInetPort(addr));
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ CoolKeyBadCertHandler overriddenHandler = CoolKeyGetBadCertHandler();
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ if(overriddenHandler) {
|
|
|
ec4b96 |
+ rv = SSL_BadCertHook( sock,
|
|
|
ec4b96 |
+ (SSLBadCertHandler)overriddenHandler,
|
|
|
ec4b96 |
+ (void *)_certData);
|
|
|
ec4b96 |
+ } else {
|
|
|
ec4b96 |
+ rv = SSL_BadCertHook( sock,
|
|
|
ec4b96 |
(SSLBadCertHandler)myBadCertHandler,
|
|
|
ec4b96 |
- &errCode );
|
|
|
ec4b96 |
+ (void *)_certData);
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
rv = SSL_SetURL( sock, serverName );
|
|
|
ec4b96 |
|
|
|
ec4b96 |
if (rv != SECSuccess ) {
|
|
|
ec4b96 |
@@ -536,8 +576,6 @@
|
|
|
ec4b96 |
sock = tcpsock;
|
|
|
ec4b96 |
}
|
|
|
ec4b96 |
|
|
|
ec4b96 |
-
|
|
|
ec4b96 |
-
|
|
|
ec4b96 |
if ( PR_Connect(sock, addr, timeout) == PR_FAILURE ) {
|
|
|
ec4b96 |
|
|
|
ec4b96 |
if( sock != NULL ) {
|
|
|
ec4b96 |
@@ -563,11 +601,17 @@
|
|
|
ec4b96 |
const PSHttpServer& server,
|
|
|
ec4b96 |
int timeout, PRBool expectChunked ,PRBool processStreamed) {
|
|
|
ec4b96 |
PRNetAddr addr;
|
|
|
ec4b96 |
- PRFileDesc *sock = NULL;
|
|
|
ec4b96 |
PSHttpResponse *resp = NULL;
|
|
|
ec4b96 |
|
|
|
ec4b96 |
PRBool response_code = 0;
|
|
|
ec4b96 |
|
|
|
ec4b96 |
+ char tBuff[56];
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ PR_LOG(httpEngineLog, PR_LOG_DEBUG,
|
|
|
ec4b96 |
+ ("%s HttpEngine::makeRequest enter. \n",GetTStamp(tBuff,56)));
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
server.getAddr(&addr);
|
|
|
ec4b96 |
|
|
|
ec4b96 |
char *nickName = request.getCertNickName();
|
|
|
ec4b96 |
@@ -575,8 +619,17 @@
|
|
|
ec4b96 |
char *serverName = (char *)server.getAddr();
|
|
|
ec4b96 |
_sock = _doConnect( &addr, request.isSSL(), 0, 0,nickName, 0, serverName );
|
|
|
ec4b96 |
|
|
|
ec4b96 |
+ PR_LOG(httpEngineLog, PR_LOG_DEBUG,
|
|
|
ec4b96 |
+ ("%s HttpEngine::makeRequest past doConnect sock: %p. \n",
|
|
|
ec4b96 |
+ GetTStamp(tBuff,56),_sock));
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
if ( _sock != NULL) {
|
|
|
ec4b96 |
PRBool status = request.send( _sock );
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ PR_LOG(httpEngineLog, PR_LOG_DEBUG,
|
|
|
ec4b96 |
+ ("%s HttpEngine::makeRequest past request.send status: %d. \n",
|
|
|
ec4b96 |
+ GetTStamp(tBuff,56),status));
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
if ( status ) {
|
|
|
ec4b96 |
resp = new PSHttpResponse( _sock, &request, timeout, expectChunked ,this);
|
|
|
ec4b96 |
response_code = resp->processResponse(processStreamed);
|
|
|
ec4b96 |
--- ./esc/src/lib/NssHttpClient/manifest.mn.fix6 2009-06-19 16:08:05.000000000 -0700
|
|
|
ec4b96 |
+++ ./esc/src/lib/NssHttpClient/manifest.mn 2009-06-19 16:08:13.000000000 -0700
|
|
|
ec4b96 |
@@ -24,7 +24,7 @@
|
|
|
ec4b96 |
MODULE = httpchunked
|
|
|
ec4b96 |
LIBRARY_NAME = $(MODULE)
|
|
|
ec4b96 |
SHARED_NAME = $(MODULE)
|
|
|
ec4b96 |
-REQUIRES = nss nspr
|
|
|
ec4b96 |
+REQUIRES = nss nspr ckymanager
|
|
|
ec4b96 |
ifndef MOZ_OFFSET
|
|
|
ec4b96 |
MOZ_OFFSET = mozilla-1.7.13
|
|
|
ec4b96 |
endif
|
|
|
ec4b96 |
--- ./esc/src/lib/coolkey/NSSManager.h.fix6 2009-06-19 16:06:41.000000000 -0700
|
|
|
ec4b96 |
+++ ./esc/src/lib/coolkey/NSSManager.h 2009-06-19 16:06:47.000000000 -0700
|
|
|
ec4b96 |
@@ -70,6 +70,8 @@
|
|
|
ec4b96 |
|
|
|
ec4b96 |
static HRESULT GetKeyCertNicknames( const CoolKey *aKey, vector<string> & aStrings );
|
|
|
ec4b96 |
|
|
|
ec4b96 |
+ static HRESULT GetKeyUID(const CoolKey *aKey, char *aBuf, int aBufLength);
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
static HRESULT GetKeyIssuedTo(const CoolKey *aKey, char *aBuf, int aBufLength);
|
|
|
ec4b96 |
|
|
|
ec4b96 |
static HRESULT GetKeyIssuer(const CoolKey *aKey, char *aBuf, int aBufLength);
|
|
|
ec4b96 |
--- ./esc/src/lib/coolkey/CoolKey.cpp.fix6 2009-06-19 16:02:43.000000000 -0700
|
|
|
ec4b96 |
+++ ./esc/src/lib/coolkey/CoolKey.cpp 2009-06-19 16:03:03.000000000 -0700
|
|
|
ec4b96 |
@@ -259,12 +259,14 @@
|
|
|
ec4b96 |
static CoolKeyRelease g_Release = NULL;
|
|
|
ec4b96 |
static CoolKeyGetConfigValue g_GetConfigValue = NULL;
|
|
|
ec4b96 |
static CoolKeySetConfigValue g_SetConfigValue = NULL;
|
|
|
ec4b96 |
+static CoolKeyBadCertHandler g_BadCertHandler = NULL;
|
|
|
ec4b96 |
|
|
|
ec4b96 |
char* CoolKeyVerifyPassword(PK11SlotInfo *,PRBool,void *);
|
|
|
ec4b96 |
|
|
|
ec4b96 |
COOLKEY_API HRESULT CoolKeySetCallbacks(CoolKeyDispatch dispatch,
|
|
|
ec4b96 |
CoolKeyReference reference, CoolKeyRelease release,
|
|
|
ec4b96 |
- CoolKeyGetConfigValue getconfigvalue,CoolKeySetConfigValue setconfigvalue)
|
|
|
ec4b96 |
+ CoolKeyGetConfigValue getconfigvalue,CoolKeySetConfigValue setconfigvalue,
|
|
|
ec4b96 |
+ CoolKeyBadCertHandler badcerthandler)
|
|
|
ec4b96 |
{
|
|
|
ec4b96 |
char tBuff[56];
|
|
|
ec4b96 |
g_Dispatch = dispatch;
|
|
|
ec4b96 |
@@ -272,6 +274,7 @@
|
|
|
ec4b96 |
g_Release = release;
|
|
|
ec4b96 |
g_GetConfigValue = getconfigvalue;
|
|
|
ec4b96 |
g_SetConfigValue = setconfigvalue;
|
|
|
ec4b96 |
+ g_BadCertHandler = badcerthandler;
|
|
|
ec4b96 |
|
|
|
ec4b96 |
char * suppressPINPrompt =(char*) CoolKeyGetConfig("esc.security.url");
|
|
|
ec4b96 |
|
|
|
ec4b96 |
@@ -997,6 +1000,16 @@
|
|
|
ec4b96 |
|
|
|
ec4b96 |
return NSSManager::GetKeyPolicy(aKey, aBuf, aBufLen);
|
|
|
ec4b96 |
}
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+HRESULT
|
|
|
ec4b96 |
+CoolKeyGetUID(const CoolKey *aKey, char *aBuf, int aBufLength)
|
|
|
ec4b96 |
+{
|
|
|
ec4b96 |
+ if (!aKey || !aKey->mKeyID || !aBuf || aBufLength < 1)
|
|
|
ec4b96 |
+ return E_FAIL;
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ return NSSManager::GetKeyUID(aKey,aBuf,aBufLength);
|
|
|
ec4b96 |
+}
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
HRESULT
|
|
|
ec4b96 |
CoolKeyGetIssuedTo(const CoolKey *aKey, char *aBuf, int aBufLength)
|
|
|
ec4b96 |
{
|
|
|
ec4b96 |
@@ -1290,6 +1303,13 @@
|
|
|
ec4b96 |
return aCUID;
|
|
|
ec4b96 |
}
|
|
|
ec4b96 |
|
|
|
ec4b96 |
+CoolKeyBadCertHandler CoolKeyGetBadCertHandler()
|
|
|
ec4b96 |
+{
|
|
|
ec4b96 |
+ if(g_BadCertHandler)
|
|
|
ec4b96 |
+ return g_BadCertHandler;
|
|
|
ec4b96 |
+ return NULL;
|
|
|
ec4b96 |
+}
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
const char *CoolKeyGetConfig(const char *aValue)
|
|
|
ec4b96 |
{
|
|
|
ec4b96 |
if(!g_GetConfigValue || ! aValue)
|
|
|
ec4b96 |
--- ./esc/src/lib/coolkey/manifest.mn.fix6 2009-06-19 16:05:45.000000000 -0700
|
|
|
ec4b96 |
+++ ./esc/src/lib/coolkey/manifest.mn 2009-06-19 16:05:54.000000000 -0700
|
|
|
ec4b96 |
@@ -19,7 +19,6 @@
|
|
|
ec4b96 |
|
|
|
ec4b96 |
XULRUNNER_BASE=$(CORE_DEPTH)/dist/$(OBJDIR)//xulrunner_build
|
|
|
ec4b96 |
|
|
|
ec4b96 |
-
|
|
|
ec4b96 |
SYS_INC = /usr/include
|
|
|
ec4b96 |
MODULE = ckymanager
|
|
|
ec4b96 |
LIBRARY_NAME = $(MODULE)
|
|
|
ec4b96 |
@@ -41,7 +40,7 @@
|
|
|
ec4b96 |
SmartCardMonitoringThread.cpp \
|
|
|
ec4b96 |
$(NULL)
|
|
|
ec4b96 |
|
|
|
ec4b96 |
-EXPORTS = \
|
|
|
ec4b96 |
+EXPORTS = \
|
|
|
ec4b96 |
CoolKey.h \
|
|
|
ec4b96 |
$(NULL)
|
|
|
ec4b96 |
|
|
|
ec4b96 |
--- ./esc/src/lib/coolkey/NSSManager.cpp.fix6 2009-06-19 16:06:19.000000000 -0700
|
|
|
ec4b96 |
+++ ./esc/src/lib/coolkey/NSSManager.cpp 2009-06-19 16:06:28.000000000 -0700
|
|
|
ec4b96 |
@@ -369,7 +369,7 @@
|
|
|
ec4b96 |
|
|
|
ec4b96 |
aBuf[0]=0;
|
|
|
ec4b96 |
|
|
|
ec4b96 |
- PR_LOG( coolKeyLogNSS, PR_LOG_DEBUG, ("%s NSSManager::GetKeyIssuedTo \n",GetTStamp(tBuff,56)));
|
|
|
ec4b96 |
+ PR_LOG( coolKeyLogNSS, PR_LOG_DEBUG, ("%s NSSManager::GetKeyIssuer \n",GetTStamp(tBuff,56)));
|
|
|
ec4b96 |
|
|
|
ec4b96 |
if(!aKey )
|
|
|
ec4b96 |
return E_FAIL;
|
|
|
ec4b96 |
@@ -409,7 +409,7 @@
|
|
|
ec4b96 |
continue;
|
|
|
ec4b96 |
}
|
|
|
ec4b96 |
orgID = CERT_GetOrgName(&cert->subject);
|
|
|
ec4b96 |
- PR_LOG( coolKeyLogNSS, PR_LOG_DEBUG, ("%s NSSManager::GetKeyIssuedTo ourSlot %p curSlot %p org %s \n",GetTStamp(tBuff,56),slot,cert->slot,orgID));
|
|
|
ec4b96 |
+ PR_LOG( coolKeyLogNSS, PR_LOG_DEBUG, ("%s NSSManager::GetKeyIssuer ourSlot %p curSlot %p org %s \n",GetTStamp(tBuff,56),slot,cert->slot,orgID));
|
|
|
ec4b96 |
|
|
|
ec4b96 |
}
|
|
|
ec4b96 |
|
|
|
ec4b96 |
@@ -437,6 +437,85 @@
|
|
|
ec4b96 |
return S_OK;
|
|
|
ec4b96 |
}
|
|
|
ec4b96 |
|
|
|
ec4b96 |
+HRESULT NSSManager::GetKeyUID(const CoolKey *aKey, char *aBuf, int aBufLength)
|
|
|
ec4b96 |
+{
|
|
|
ec4b96 |
+ char tBuff[56];
|
|
|
ec4b96 |
+ if(!aBuf)
|
|
|
ec4b96 |
+ return E_FAIL;
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ aBuf[0]=0;
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ PR_LOG( coolKeyLogNSS, PR_LOG_DEBUG, ("%s NSSManager::GetKeyUID \n",GetTStamp(tBuff,56)));
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ if(!aKey )
|
|
|
ec4b96 |
+ return E_FAIL;
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ PK11SlotInfo *slot = GetSlotForKeyID(aKey);
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ if (!slot)
|
|
|
ec4b96 |
+ return E_FAIL;
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ CERTCertList *certs = PK11_ListCerts(PK11CertListAll,NULL);
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ if (!certs)
|
|
|
ec4b96 |
+ {
|
|
|
ec4b96 |
+ PR_LOG( coolKeyLogNSS, PR_LOG_DEBUG, ("%sNSSManager::GetKeyUID no certs found! \n",GetTStamp(tBuff,56)));
|
|
|
ec4b96 |
+ PK11_FreeSlot(slot);
|
|
|
ec4b96 |
+ return E_FAIL;
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ CERTCertListNode *node= NULL;
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ char *certID = NULL;
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ for( node = CERT_LIST_HEAD(certs);
|
|
|
ec4b96 |
+ ! CERT_LIST_END(node, certs);
|
|
|
ec4b96 |
+ node = CERT_LIST_NEXT(node))
|
|
|
ec4b96 |
+ {
|
|
|
ec4b96 |
+ if(node->cert)
|
|
|
ec4b96 |
+ {
|
|
|
ec4b96 |
+ CERTCertificate *cert = node->cert;
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ if(cert)
|
|
|
ec4b96 |
+ {
|
|
|
ec4b96 |
+ if(cert->slot == slot)
|
|
|
ec4b96 |
+ {
|
|
|
ec4b96 |
+ if(IsCACert(cert))
|
|
|
ec4b96 |
+ {
|
|
|
ec4b96 |
+ continue;
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ certID = CERT_GetCertUid(&cert->subject);
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ PR_LOG( coolKeyLogNSS, PR_LOG_DEBUG, ("%s NSSManager::GetKeyUID ourSlot %p curSlot %p certID %s \n",GetTStamp(tBuff,56),slot,cert->slot,certID));
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ if(certID)
|
|
|
ec4b96 |
+ break;
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ if(certID && ((int)strlen(certID) < aBufLength))
|
|
|
ec4b96 |
+ {
|
|
|
ec4b96 |
+ strcpy(aBuf,certID);
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ if(certs)
|
|
|
ec4b96 |
+ CERT_DestroyCertList(certs);
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ if(slot)
|
|
|
ec4b96 |
+ PK11_FreeSlot(slot);
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ if(certID)
|
|
|
ec4b96 |
+ PORT_Free(certID);
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ return S_OK;
|
|
|
ec4b96 |
+}
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
HRESULT NSSManager::GetKeyIssuedTo(const CoolKey *aKey, char *aBuf, int aBufLength)
|
|
|
ec4b96 |
{
|
|
|
ec4b96 |
char tBuff[56];
|
|
|
ec4b96 |
@@ -487,6 +566,10 @@
|
|
|
ec4b96 |
|
|
|
ec4b96 |
certID = CERT_GetCommonName(&cert->subject);
|
|
|
ec4b96 |
|
|
|
ec4b96 |
+ if(!certID) {
|
|
|
ec4b96 |
+ certID = CERT_GetCertUid(&cert->subject);
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
PR_LOG( coolKeyLogNSS, PR_LOG_DEBUG, ("%s NSSManager::GetKeyIssuedTo ourSlot %p curSlot %p certID %s \n",GetTStamp(tBuff,56),slot,cert->slot,certID));
|
|
|
ec4b96 |
|
|
|
ec4b96 |
}
|
|
|
ec4b96 |
--- ./esc/src/lib/coolkey/CoolKey.h.fix6 2009-06-19 16:04:59.000000000 -0700
|
|
|
ec4b96 |
+++ ./esc/src/lib/coolkey/CoolKey.h 2009-06-19 16:05:05.000000000 -0700
|
|
|
ec4b96 |
@@ -26,6 +26,7 @@
|
|
|
ec4b96 |
// platforms (coreconf will do the appropriate processing.
|
|
|
ec4b96 |
#define COOLKEY_API
|
|
|
ec4b96 |
|
|
|
ec4b96 |
+#include "ssl.h"
|
|
|
ec4b96 |
#include <string.h>
|
|
|
ec4b96 |
#include <stdlib.h>
|
|
|
ec4b96 |
#include <vector>
|
|
|
ec4b96 |
@@ -100,7 +101,7 @@
|
|
|
ec4b96 |
|
|
|
ec4b96 |
typedef HRESULT (*CoolKeySetConfigValue)(const char *name,const char *value);
|
|
|
ec4b96 |
typedef const char * (*CoolKeyGetConfigValue)(const char *name);
|
|
|
ec4b96 |
-
|
|
|
ec4b96 |
+typedef SECStatus (*CoolKeyBadCertHandler)(void *arg, PRFileDesc *fd);
|
|
|
ec4b96 |
|
|
|
ec4b96 |
|
|
|
ec4b96 |
extern "C" {
|
|
|
ec4b96 |
@@ -112,7 +113,8 @@
|
|
|
ec4b96 |
COOLKEY_API HRESULT CoolKeyUnregisterListener(CoolKeyListener* aListener);
|
|
|
ec4b96 |
COOLKEY_API HRESULT CoolKeySetCallbacks(CoolKeyDispatch dispatch,
|
|
|
ec4b96 |
CoolKeyReference reference, CoolKeyRelease release,
|
|
|
ec4b96 |
- CoolKeyGetConfigValue getconfigvalue,CoolKeySetConfigValue setconfigvalue);
|
|
|
ec4b96 |
+ CoolKeyGetConfigValue getconfigvalue,CoolKeySetConfigValue setconfigvalue,
|
|
|
ec4b96 |
+ CoolKeyBadCertHandler badcerthandler=NULL);
|
|
|
ec4b96 |
|
|
|
ec4b96 |
COOLKEY_API bool CoolKeyRequiresAuthentication(const CoolKey *aKey);
|
|
|
ec4b96 |
COOLKEY_API bool CoolKeyHasApplet(const CoolKey *aKey);
|
|
|
ec4b96 |
@@ -133,6 +135,8 @@
|
|
|
ec4b96 |
|
|
|
ec4b96 |
COOLKEY_API HRESULT CoolKeyGetCertInfo(const CoolKey *aKey, char *aCertNickname, std::string & aCertInfo);
|
|
|
ec4b96 |
|
|
|
ec4b96 |
+COOLKEY_API HRESULT CoolKeyGetUID(const CoolKey *aKey, char *aBuf, int aBufLength);
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
COOLKEY_API HRESULT CoolKeyGetIssuedTo(const CoolKey *aKey, char *aBuf, int aBufLength);
|
|
|
ec4b96 |
COOLKEY_API HRESULT CoolKeyGetIssuer(const CoolKey *aKey, char *aBuf, int aBufLength);
|
|
|
ec4b96 |
|
|
|
ec4b96 |
@@ -257,6 +261,9 @@
|
|
|
ec4b96 |
|
|
|
ec4b96 |
const char *CoolKeyGetConfig(const char *aName);
|
|
|
ec4b96 |
HRESULT CoolKeySetConfig(const char *aName,const char *aValue);
|
|
|
ec4b96 |
+CoolKeyBadCertHandler CoolKeyGetBadCertHandler();
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
|
|
|
ec4b96 |
}
|
|
|
ec4b96 |
|
|
|
ec4b96 |
--- ./esc/src/lib/coolkey/Makefile.fix6 2009-06-19 16:05:24.000000000 -0700
|
|
|
ec4b96 |
+++ ./esc/src/lib/coolkey/Makefile 2009-06-19 16:05:32.000000000 -0700
|
|
|
ec4b96 |
@@ -35,6 +35,9 @@
|
|
|
ec4b96 |
echo "Build Linux or Windows."
|
|
|
ec4b96 |
make -f common.mk
|
|
|
ec4b96 |
|
|
|
ec4b96 |
+export::
|
|
|
ec4b96 |
+ make -f common.mk export
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
endif
|
|
|
ec4b96 |
|
|
|
ec4b96 |
ifeq ($(OS_ARCH),Darwin)
|
|
|
ec4b96 |
--- ./esc/src/app/xul/esc/chrome/content/esc/certManager.xul.fix6 2009-06-19 16:01:21.000000000 -0700
|
|
|
ec4b96 |
+++ ./esc/src/app/xul/esc/chrome/content/esc/certManager.xul 2009-06-19 16:01:43.000000000 -0700
|
|
|
ec4b96 |
@@ -65,7 +65,7 @@
|
|
|
ec4b96 |
<tabs id="certMgrTabbox" onselect="CertsTabsSelected();">
|
|
|
ec4b96 |
<tab id="mine_tab" label="&certmgr.tab.mine;" selected="true"/>
|
|
|
ec4b96 |
<tab id="others_tab" hidden="true" label="&certmgr.tab.others2;"/>
|
|
|
ec4b96 |
- <tab id="websites_tab" hidden="true" label="&certmgr.tab.websites3;"/>
|
|
|
ec4b96 |
+ <tab id="websites_tab" hidden="false" label="&certmgr.tab.websites3;"/>
|
|
|
ec4b96 |
<tab id="ca_tab" hidden="false" label="&certmgr.tab.ca;"/>
|
|
|
ec4b96 |
<tab id="orphan_tab" hidden="true" label="&certmgr.tab.orphan2;"/>
|
|
|
ec4b96 |
|
|
|
ec4b96 |
--- ./esc/src/app/xpcom/rhCoolKey.cpp.fix6 2009-06-19 15:56:20.000000000 -0700
|
|
|
ec4b96 |
+++ ./esc/src/app/xpcom/rhCoolKey.cpp 2009-06-19 15:57:48.000000000 -0700
|
|
|
ec4b96 |
@@ -30,7 +30,7 @@
|
|
|
ec4b96 |
#else
|
|
|
ec4b96 |
#include "nsServiceManagerUtils.h"
|
|
|
ec4b96 |
#endif
|
|
|
ec4b96 |
-
|
|
|
ec4b96 |
+#include "pipnss/nsICertOverrideService.h"
|
|
|
ec4b96 |
#include "nsIPrefBranch.h"
|
|
|
ec4b96 |
#include "nsIPrefService.h"
|
|
|
ec4b96 |
#include "nsCOMPtr.h"
|
|
|
ec4b96 |
@@ -69,6 +69,7 @@
|
|
|
ec4b96 |
#endif
|
|
|
ec4b96 |
|
|
|
ec4b96 |
#define PSM_COMPONENT_CONTRACTID "@mozilla.org/psm;1"
|
|
|
ec4b96 |
+#define NS_CERTOVERRIDE_CONTRACTID "@mozilla.org/security/certoverride;1"
|
|
|
ec4b96 |
|
|
|
ec4b96 |
static const nsIID kIModuleIID = NS_IMODULE_IID;
|
|
|
ec4b96 |
static const nsIID kIFactoryIID = NS_IFACTORY_IID;
|
|
|
ec4b96 |
@@ -89,6 +90,7 @@
|
|
|
ec4b96 |
|
|
|
ec4b96 |
std::list< nsCOMPtr <rhIKeyNotify> > rhCoolKey::gNotifyListeners;
|
|
|
ec4b96 |
|
|
|
ec4b96 |
+PRLock* rhCoolKey::certCBLock=NULL;
|
|
|
ec4b96 |
|
|
|
ec4b96 |
PRBool rhCoolKey::gAutoEnrollBlankTokens = PR_FALSE;
|
|
|
ec4b96 |
|
|
|
ec4b96 |
@@ -190,6 +192,13 @@
|
|
|
ec4b96 |
mCSPListener = nsnull;
|
|
|
ec4b96 |
#endif
|
|
|
ec4b96 |
|
|
|
ec4b96 |
+ certCBLock = PR_NewLock();
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ if(!certCBLock) {
|
|
|
ec4b96 |
+ PR_LOG( coolKeyLog, PR_LOG_ERROR, ("%s Failed to create lock exiting! \n",GetTStamp(tBuff,56)));
|
|
|
ec4b96 |
+ exit(1);
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
PRBool res = InitInstance();
|
|
|
ec4b96 |
|
|
|
ec4b96 |
if(res == PR_FALSE)
|
|
|
ec4b96 |
@@ -207,6 +216,10 @@
|
|
|
ec4b96 |
|
|
|
ec4b96 |
char tBuff[56];
|
|
|
ec4b96 |
PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s rhCoolKey::~rhCoolKey: %p \n",GetTStamp(tBuff,56),this));
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ if(certCBLock) {
|
|
|
ec4b96 |
+ PR_DestroyLock(certCBLock);
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
}
|
|
|
ec4b96 |
|
|
|
ec4b96 |
void rhCoolKey::ShutDownInstance()
|
|
|
ec4b96 |
@@ -255,6 +268,212 @@
|
|
|
ec4b96 |
return S_OK;
|
|
|
ec4b96 |
}
|
|
|
ec4b96 |
|
|
|
ec4b96 |
+struct BadCertData {
|
|
|
ec4b96 |
+ PRErrorCode error;
|
|
|
ec4b96 |
+ PRInt32 port;
|
|
|
ec4b96 |
+};
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+typedef struct BadCertData BadCertData;
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+SECStatus rhCoolKey::badCertHandler(void *arg, PRFileDesc *fd)
|
|
|
ec4b96 |
+{
|
|
|
ec4b96 |
+ SECStatus secStatus = SECFailure;
|
|
|
ec4b96 |
+ PRErrorCode err;
|
|
|
ec4b96 |
+ char *host = NULL;
|
|
|
ec4b96 |
+ PRInt32 port = 0;
|
|
|
ec4b96 |
+ CERTCertificate *serverCert = NULL;
|
|
|
ec4b96 |
+ PRUint32 errorBits = 0;
|
|
|
ec4b96 |
+ char tBuff[56];
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ PR_Lock(certCBLock);
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ if (!arg || !fd) {
|
|
|
ec4b96 |
+ PR_Unlock(certCBLock);
|
|
|
ec4b96 |
+ return secStatus;
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ // Retrieve callback data from NssHttpClient
|
|
|
ec4b96 |
+ // Caller cleans up this data
|
|
|
ec4b96 |
+ BadCertData *data = (BadCertData *) arg;
|
|
|
ec4b96 |
+ data->error = err = PORT_GetError();
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ /* If any of the cases in the switch are met, then we will proceed */
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ switch (err) {
|
|
|
ec4b96 |
+ case SEC_ERROR_INVALID_AVA:
|
|
|
ec4b96 |
+ case SEC_ERROR_INVALID_TIME:
|
|
|
ec4b96 |
+ case SEC_ERROR_BAD_SIGNATURE:
|
|
|
ec4b96 |
+ case SEC_ERROR_EXPIRED_CERTIFICATE:
|
|
|
ec4b96 |
+ case SEC_ERROR_UNKNOWN_ISSUER:
|
|
|
ec4b96 |
+ case SEC_ERROR_UNTRUSTED_CERT:
|
|
|
ec4b96 |
+ case SEC_ERROR_CERT_VALID:
|
|
|
ec4b96 |
+ case SEC_ERROR_EXPIRED_ISSUER_CERTIFICATE:
|
|
|
ec4b96 |
+ case SEC_ERROR_CRL_EXPIRED:
|
|
|
ec4b96 |
+ case SEC_ERROR_CRL_BAD_SIGNATURE:
|
|
|
ec4b96 |
+ case SEC_ERROR_EXTENSION_VALUE_INVALID:
|
|
|
ec4b96 |
+ case SEC_ERROR_CA_CERT_INVALID:
|
|
|
ec4b96 |
+ case SEC_ERROR_CERT_USAGES_INVALID:
|
|
|
ec4b96 |
+ case SEC_ERROR_UNKNOWN_CRITICAL_EXTENSION:
|
|
|
ec4b96 |
+ case SEC_ERROR_EXTENSION_NOT_FOUND: // Added by Rob 5/21/2002
|
|
|
ec4b96 |
+ secStatus = SECSuccess;
|
|
|
ec4b96 |
+ break;
|
|
|
ec4b96 |
+ default:
|
|
|
ec4b96 |
+ secStatus = SECFailure;
|
|
|
ec4b96 |
+ break;
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ if(secStatus == SECSuccess) {
|
|
|
ec4b96 |
+ PR_Unlock(certCBLock);
|
|
|
ec4b96 |
+ return secStatus;
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ // Collect errors to compare with override service output
|
|
|
ec4b96 |
+ switch(err) {
|
|
|
ec4b96 |
+ case SEC_ERROR_UNTRUSTED_ISSUER:
|
|
|
ec4b96 |
+ errorBits |= nsICertOverrideService::ERROR_UNTRUSTED;
|
|
|
ec4b96 |
+ break;
|
|
|
ec4b96 |
+ case SSL_ERROR_BAD_CERT_DOMAIN:
|
|
|
ec4b96 |
+ errorBits |= nsICertOverrideService::ERROR_MISMATCH;
|
|
|
ec4b96 |
+ break;
|
|
|
ec4b96 |
+ case SEC_ERROR_EXPIRED_CERTIFICATE:
|
|
|
ec4b96 |
+ errorBits |= nsICertOverrideService::ERROR_TIME;
|
|
|
ec4b96 |
+ default:
|
|
|
ec4b96 |
+ break;
|
|
|
ec4b96 |
+ };
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ // Now proceed to see if we have an exception.
|
|
|
ec4b96 |
+ // Get the server certificate that was rejected.
|
|
|
ec4b96 |
+ serverCert = SSL_PeerCertificate(fd);
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ if(!serverCert) {
|
|
|
ec4b96 |
+ PR_Unlock(certCBLock);
|
|
|
ec4b96 |
+ return secStatus;
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ port = data->port;
|
|
|
ec4b96 |
+ host = SSL_RevealURL(fd);
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ if(!host || port <= 0) {
|
|
|
ec4b96 |
+ PR_Unlock(certCBLock);
|
|
|
ec4b96 |
+ return secStatus;
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ PR_LOG(coolKeyLog, PR_LOG_DEBUG,
|
|
|
ec4b96 |
+ ("%s rhCoolKey::badCertHandler enter: error: %d url: %s port: %d \n",
|
|
|
ec4b96 |
+ GetTStamp(tBuff,56),err,host,port)
|
|
|
ec4b96 |
+ );
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ PRBool isTemporaryOverride = PR_FALSE;
|
|
|
ec4b96 |
+ PRUint32 overrideBits = 0;
|
|
|
ec4b96 |
+ PRBool overrideResult = PR_FALSE;
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ // Use the nsICertOverrideService to see if we have
|
|
|
ec4b96 |
+ // previously trusted this certificate.
|
|
|
ec4b96 |
+ nsCOMPtr<nsICertOverrideService> overrideService =
|
|
|
ec4b96 |
+ do_GetService(NS_CERTOVERRIDE_CONTRACTID);
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ const nsEmbedCString nsHost(host);
|
|
|
ec4b96 |
+ nsEmbedCString hashAlg,fingerPrint;
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ nsresult nsrv;
|
|
|
ec4b96 |
+ unsigned char* fingerprint=NULL;
|
|
|
ec4b96 |
+ if(overrideService) {
|
|
|
ec4b96 |
+ nsrv = overrideService->GetValidityOverride((const nsACString &)nsHost,
|
|
|
ec4b96 |
+ port,(nsACString &)hashAlg,
|
|
|
ec4b96 |
+ (nsACString&)fingerPrint,&overrideBits,
|
|
|
ec4b96 |
+ &isTemporaryOverride,&overrideResult
|
|
|
ec4b96 |
+ );
|
|
|
ec4b96 |
+ if(nsrv == NS_OK) {
|
|
|
ec4b96 |
+ PR_LOG(coolKeyLog, PR_LOG_DEBUG,
|
|
|
ec4b96 |
+ ("%s rhCoolKey::badCertHandler res %d print %s len %d bits %u temp %d alg: %s \n",
|
|
|
ec4b96 |
+ GetTStamp(tBuff,56),overrideResult,fingerPrint.get(),
|
|
|
ec4b96 |
+ fingerPrint.Length(),overrideBits, isTemporaryOverride,hashAlg.get())
|
|
|
ec4b96 |
+ );
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ PRBool certMatches = PR_FALSE;
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ if( (nsrv == NS_OK) && overrideResult) {
|
|
|
ec4b96 |
+ SECItem oid;
|
|
|
ec4b96 |
+ oid.data = nsnull;
|
|
|
ec4b96 |
+ oid.len = 0;
|
|
|
ec4b96 |
+ SECStatus srv = SEC_StringToOID(nsnull, &oid,
|
|
|
ec4b96 |
+ hashAlg.get(), hashAlg.Length());
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ if (srv != SECSuccess) {
|
|
|
ec4b96 |
+ PR_Free(host);
|
|
|
ec4b96 |
+ host=NULL;
|
|
|
ec4b96 |
+ CERT_DestroyCertificate(serverCert);
|
|
|
ec4b96 |
+ serverCert=NULL;
|
|
|
ec4b96 |
+ PR_Unlock(certCBLock);
|
|
|
ec4b96 |
+ return secStatus;
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ SECOidTag oid_tag = SECOID_FindOIDTag(&oid;;
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ unsigned int hash_len = HASH_ResultLenByOidTag(oid_tag);
|
|
|
ec4b96 |
+ fingerprint = new unsigned char[hash_len];
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ if(!fingerprint) {
|
|
|
ec4b96 |
+ CERT_DestroyCertificate(serverCert);
|
|
|
ec4b96 |
+ serverCert=NULL;
|
|
|
ec4b96 |
+ PR_Unlock(certCBLock);
|
|
|
ec4b96 |
+ return secStatus;
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ SECItem computedPrint;
|
|
|
ec4b96 |
+ memset(fingerprint, 0, sizeof fingerprint);
|
|
|
ec4b96 |
+ PK11_HashBuf(oid_tag, fingerprint,
|
|
|
ec4b96 |
+ serverCert->derCert.data, serverCert->derCert.len);
|
|
|
ec4b96 |
+ CERT_DestroyCertificate(serverCert);
|
|
|
ec4b96 |
+ serverCert=NULL;
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ computedPrint.data=fingerprint;
|
|
|
ec4b96 |
+ computedPrint.len=hash_len;
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ char *formattedPrint = CERT_Hexify(&computedPrint,1);
|
|
|
ec4b96 |
+ char *inputPrint = (char *)fingerPrint.get();
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ //Compare fingerprints.
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ if(formattedPrint && inputPrint) {
|
|
|
ec4b96 |
+ if(!PL_strcmp(formattedPrint, inputPrint))
|
|
|
ec4b96 |
+ certMatches = PR_TRUE;
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s certMatches: %d \n",
|
|
|
ec4b96 |
+ GetTStamp(tBuff,56),certMatches)
|
|
|
ec4b96 |
+ );
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ if(formattedPrint) {
|
|
|
ec4b96 |
+ PORT_Free(formattedPrint);
|
|
|
ec4b96 |
+ formattedPrint = NULL;
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+ } else {
|
|
|
ec4b96 |
+ PR_LOG( coolKeyLog, PR_LOG_DEBUG, ("%s override test failed. \n",
|
|
|
ec4b96 |
+ GetTStamp(tBuff,56))
|
|
|
ec4b96 |
+ );
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ if( certMatches ) {
|
|
|
ec4b96 |
+ if(overrideBits | errorBits)
|
|
|
ec4b96 |
+ secStatus = SECSuccess;
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ PR_Free(host);
|
|
|
ec4b96 |
+ host = NULL;
|
|
|
ec4b96 |
+ if(fingerprint) {
|
|
|
ec4b96 |
+ delete [] fingerprint;
|
|
|
ec4b96 |
+ fingerprint = NULL;
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ PR_Unlock(certCBLock);
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ return secStatus;
|
|
|
ec4b96 |
+}
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
HRESULT rhCoolKey::doSetCoolKeyConfigValue(const char *aName, const char *aValue)
|
|
|
ec4b96 |
{
|
|
|
ec4b96 |
|
|
|
ec4b96 |
@@ -340,7 +559,7 @@
|
|
|
ec4b96 |
nssComponent
|
|
|
ec4b96 |
= do_GetService(PSM_COMPONENT_CONTRACTID);
|
|
|
ec4b96 |
|
|
|
ec4b96 |
- CoolKeySetCallbacks(Dispatch,Reference, Release,doGetCoolKeyConfigValue ,doSetCoolKeyConfigValue);
|
|
|
ec4b96 |
+ CoolKeySetCallbacks(Dispatch,Reference, Release,doGetCoolKeyConfigValue ,doSetCoolKeyConfigValue,badCertHandler);
|
|
|
ec4b96 |
|
|
|
ec4b96 |
mProxy = CreateProxyObject();
|
|
|
ec4b96 |
|
|
|
ec4b96 |
@@ -1262,6 +1481,38 @@
|
|
|
ec4b96 |
}
|
|
|
ec4b96 |
|
|
|
ec4b96 |
/* string GetCoolKeyIssuedTo (in unsigned long aKeyType, in string aKeyID); */
|
|
|
ec4b96 |
+NS_IMETHODIMP rhCoolKey::GetCoolKeyUID(PRUint32 aKeyType, const char *aKeyID, char **uid)
|
|
|
ec4b96 |
+{
|
|
|
ec4b96 |
+ char tBuff[56];
|
|
|
ec4b96 |
+ if (!aKeyID) {
|
|
|
ec4b96 |
+ return NS_ERROR_FAILURE;
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ AutoCoolKey key(aKeyType, ( char *)aKeyID);
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ char buff[512];
|
|
|
ec4b96 |
+ int bufLength = 512;
|
|
|
ec4b96 |
+ buff[0] = 0;
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ CoolKeyGetUID(&key, (char *) buff, bufLength);
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ if(!buff[0])
|
|
|
ec4b96 |
+ {
|
|
|
ec4b96 |
+ return NS_OK;
|
|
|
ec4b96 |
+ }
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ PR_LOG(coolKeyLog,PR_LOG_DEBUG,("%s rhCoolKey::RhGetCoolKeyGetUID %s \n",GetTStamp(tBuff,56),(char *) buff));
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ char *temp = (char *) nsMemory::Clone(buff,sizeof(char) * strlen(buff) + 1);
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ *uid = temp;
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+ return NS_OK;
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+}
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
+/* string GetCoolKeyIssuedTo (in unsigned long aKeyType, in string aKeyID); */
|
|
|
ec4b96 |
NS_IMETHODIMP rhCoolKey::GetCoolKeyIssuedTo(PRUint32 aKeyType, const char *aKeyID, char **issuedTo)
|
|
|
ec4b96 |
{
|
|
|
ec4b96 |
char tBuff[56];
|
|
|
ec4b96 |
--- ./esc/src/app/xpcom/rhICoolKey.idl.fix6 2009-06-19 16:00:20.000000000 -0700
|
|
|
ec4b96 |
+++ ./esc/src/app/xpcom/rhICoolKey.idl 2009-06-19 16:00:32.000000000 -0700
|
|
|
ec4b96 |
@@ -66,6 +66,8 @@
|
|
|
ec4b96 |
|
|
|
ec4b96 |
string GetCoolKeyCertInfo(in unsigned long aKeyType, in string aKeyID, in string aCertNickname);
|
|
|
ec4b96 |
|
|
|
ec4b96 |
+ string GetCoolKeyUID(in unsigned long aKeyType, in string aKeyID);
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
string GetCoolKeyIssuedTo(in unsigned long aKeyType, in string aKeyID);
|
|
|
ec4b96 |
|
|
|
ec4b96 |
string GetCoolKeyIssuer(in unsigned long aKeyType, in string aKeyID);
|
|
|
ec4b96 |
--- ./esc/src/app/xpcom/Makefile.sdk.fix6 2009-06-19 15:54:52.000000000 -0700
|
|
|
ec4b96 |
+++ ./esc/src/app/xpcom/Makefile.sdk 2009-06-19 15:55:43.000000000 -0700
|
|
|
ec4b96 |
@@ -109,7 +109,7 @@
|
|
|
ec4b96 |
CPPFLAGS += -fno-rtti \
|
|
|
ec4b96 |
-fno-exceptions \
|
|
|
ec4b96 |
-fshort-wchar -fPIC
|
|
|
ec4b96 |
-GECKO_LD_LIBS=-L$(GECKO_SDK_PATH)/lib $(GECKO_SDK_PATH)/lib/libxpcomglue.a -lnss3 -lcrmf -lssl3 -lsmime3 -lplds4 -lplc4 -lnspr4 -lpthread -ldl
|
|
|
ec4b96 |
+GECKO_LD_LIBS=-L$(GECKO_SDK_PATH)/lib $(GECKO_SDK_PATH)/lib/libxpcomglue.a -lnssutil3 -lnss3 -lcrmf -lssl3 -lsmime3 -lplds4 -lplc4 -lnspr4 -lpthread -ldl
|
|
|
ec4b96 |
endif
|
|
|
ec4b96 |
|
|
|
ec4b96 |
ifeq ($(OS_ARCH),WINNT)
|
|
|
ec4b96 |
@@ -145,7 +145,7 @@
|
|
|
ec4b96 |
GECKO_INCLUDES += -I $(GECKO_SDK_PATH)/sdk/include
|
|
|
ec4b96 |
OBJECT = rhCoolKey.obj
|
|
|
ec4b96 |
OBJECTCSP = CoolKeyCSP.obj
|
|
|
ec4b96 |
-COOL_LDFLAGS = -IMPLIB:fake-import /LIBPATH:$(CORE_DIST)/lib ckymanager.lib httpchunked.lib $(GECKO_LD_LIBS) nss3.lib ssl3.lib smime3.lib softokn3.lib /LIBPATH:$(CKY_LIB_LDD) libckyapplet.lib crypt32.lib kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib /NODEFAULTLIB:libc.lib
|
|
|
ec4b96 |
+COOL_LDFLAGS = -IMPLIB:fake-import /LIBPATH:$(CORE_DIST)/lib ckymanager.lib httpchunked.lib $(GECKO_LD_LIBS) nssutil3.lib nss3.lib ssl3.lib smime3.lib softokn3.lib /LIBPATH:$(CKY_LIB_LDD) libckyapplet.lib crypt32.lib kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib /NODEFAULTLIB:libc.lib
|
|
|
ec4b96 |
endif
|
|
|
ec4b96 |
|
|
|
ec4b96 |
ifeq ($(OS_ARCH),Darwin)
|
|
|
ec4b96 |
--- ./esc/src/app/xpcom/rhCoolKey.h.fix6 2009-06-19 15:58:21.000000000 -0700
|
|
|
ec4b96 |
+++ ./esc/src/app/xpcom/rhCoolKey.h 2009-06-19 15:58:28.000000000 -0700
|
|
|
ec4b96 |
@@ -22,6 +22,15 @@
|
|
|
ec4b96 |
#include "nsIGenericFactory.h"
|
|
|
ec4b96 |
#include "nsEmbedString.h"
|
|
|
ec4b96 |
#include <list>
|
|
|
ec4b96 |
+#include "nspr.h"
|
|
|
ec4b96 |
+#include "prio.h"
|
|
|
ec4b96 |
+#include "ssl.h"
|
|
|
ec4b96 |
+#include "pk11func.h"
|
|
|
ec4b96 |
+#include "cert.h"
|
|
|
ec4b96 |
+#include "sslerr.h"
|
|
|
ec4b96 |
+#include "secerr.h"
|
|
|
ec4b96 |
+#include "sechash.h"
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
#include "CoolKey.h"
|
|
|
ec4b96 |
#include "nsCOMPtr.h"
|
|
|
ec4b96 |
#include "nsIObserver.h"
|
|
|
ec4b96 |
@@ -92,6 +101,7 @@
|
|
|
ec4b96 |
|
|
|
ec4b96 |
static HRESULT doSetCoolKeyConfigValue(const char *aName, const char *aValue);
|
|
|
ec4b96 |
static const char *doGetCoolKeyConfigValue(const char *aName );
|
|
|
ec4b96 |
+ static SECStatus badCertHandler(void *arg, PRFileDesc *fd);
|
|
|
ec4b96 |
|
|
|
ec4b96 |
protected:
|
|
|
ec4b96 |
/* additional members */
|
|
|
ec4b96 |
@@ -107,6 +117,8 @@
|
|
|
ec4b96 |
|
|
|
ec4b96 |
static std::list< nsCOMPtr <rhIKeyNotify> > gNotifyListeners;
|
|
|
ec4b96 |
|
|
|
ec4b96 |
+ static PRLock* certCBLock;
|
|
|
ec4b96 |
+
|
|
|
ec4b96 |
rhICoolKey* mProxy;
|
|
|
ec4b96 |
|
|
|
ec4b96 |
static PRBool gAutoEnrollBlankTokens;
|