261667
diff -up ./esc/esc-1.1.2/esc/src/app/esc.js.fix10 ./esc/esc-1.1.2/esc/src/app/esc.js
261667
--- ./esc/src/app/esc.js.fix10	2020-12-02 15:47:00.688951279 -0800
261667
+++ ./esc/src/app/esc.js	2020-12-02 15:47:00.690951273 -0800
261667
@@ -370,12 +370,20 @@ class ESC {
261667
          let nick = "";
261667
          if(certObj.token == null) 
261667
              token = "internal"; 
261667
-         else
261667
+         else  {
261667
              token = certObj.token;
261667
+	}
261667
 
261667
          nick = certObj.nick;
261667
- 
261667
-         certDetail = this._execProgram(['/usr/bin/certutil','-L','-d', this._getConfigPath(), '-h', token, '-f' , pFileName, '-n', token + ":" + nick]);
261667
+
261667
+	 let tokenNick = '"' + token + ":" + nick + '"' ;
261667
+	 token = '"' + token + '"';
261667
+	 let argv1 = ['/usr/bin/certutil','-L','-d', this._getConfigPath(), '-h', token, '-f' , pFileName, '-n', tokenNick];
261667
+	  
261667
+         print("argv1: " + argv1);
261667
+	 
261667
+
261667
+	 certDetail = this._execProgram(argv1);
261667
 
261667
          return certDetail;
261667
      }
261667
@@ -475,7 +483,7 @@ class ESC {
261667
                result = -1;
261667
                return result;
261667
             }
261667
-
261667
+		
261667
             result = stdoutb.toString();
261667
 
261667
         } catch (e) {
261667
@@ -792,19 +800,18 @@ class ESC {
261667
         let status = this._selectedTokenInfo.status;
261667
 
261667
         if(status == 4 /* enrolled */) {
261667
-            this._pinMgr = new PinDialog.pinDialog(this);
261667
-            this._pinMgr.launchPinPrompt(this._promptPinDone.bind(this));
261667
+	    let coolkey_token = this._selectedTokenInfo;
261667
+
261667
+            this._tokenInfoBuffer.text +=
261667
+                this.mgr.get_certs_info(coolkey_token);
261667
+
261667
         }
261667
       
261667
     }
261667
-    _promptPinDone(tempFileName) {
261667
-
261667
-        let coolkey_token = this._selectedTokenInfo;
261667
-
261667
-        this._tokenInfoBuffer.text += 
261667
-              this._getCertList(coolkey_token,tempFileName)  + "\n";
261667
 
261667
+    _promptPinDone(tempFileName) {
261667
      }
261667
+
261667
     _response_cb() {
261667
         if(this._messageDialog) {
261667
             this._messageDialog.destroy();
261667
diff -up ./esc/src/app/opensc.esc.conf.fix10 ./esc/src/app/opensc.esc.conf
261667
--- ./esc/src/app/opensc.esc.conf.fix10	2020-12-02 15:51:05.812283690 -0800
261667
+++ ./esc/src/app/opensc.esc.conf	2020-12-02 15:51:30.835215539 -0800
261667
@@ -94,6 +94,7 @@ app default {
261667
         module_path = /usr/lib64;
261667
     }
261667
     framework pkcs15 {
261667
+        use_file_caching = true;
261667
         builtin_emulators = coolkey, cac, cac1, PIV-II;
261667
     }
261667
 }
261667
diff -up ./esc/src/app/pinDialog.js.fix10 ./esc/src/app/pinDialog.js
261667
--- ./esc/src/app/pinDialog.js.fix10	2020-12-02 15:47:00.683951293 -0800
261667
+++ ./esc/src/app/pinDialog.js	2020-12-02 15:47:00.691951271 -0800
261667
@@ -94,7 +94,6 @@ pinDialog.prototype = {
261667
             if(this.notify) {
261667
                 this.notify(this.tempFileName);
261667
             }
261667
-
261667
             this.clearTempFile();
261667
             this.dialog.destroy();
261667
             this.dialog = null;
261667
diff -up ./esc/src/lib/coolkey/CoolKeyHandler.cpp.fix10 ./esc/src/lib/coolkey/CoolKeyHandler.cpp
261667
--- ./esc/src/lib/coolkey/CoolKeyHandler.cpp.fix10	2020-12-02 16:25:29.075670723 -0800
261667
+++ ./esc/src/lib/coolkey/CoolKeyHandler.cpp	2020-12-02 16:30:53.310789119 -0800
261667
@@ -46,6 +46,7 @@
261667
 
261667
 static const char *cac_manu_id= "Common Access Card";
261667
 static const char *piv_manu_id= "piv II ";
261667
+static const char *piv_manu_id_1=  "piv_II";
261667
 
261667
 //static  char *test_extended_login = "s=325&msg_type=13&invalid_login=0&blocked=0&error=&required_parameter0=id%3DUSER%5FID%26name%3DUser+ID%26desc%3DUser+ID%26type%3Dstring%26option%3Doption1%2Coption2%2Coption3&required_parameter1=id%3DUSER%5FPWD%26name%3DUser+Password%26desc%3DUser+Password%26type%3Dpassword%26option%3D&required_parameter2=id%3DUSER%5FPIN%26name%3DPIN%26desc%3DOne+time+PIN+received+via+mail%26type%3Dpassword%26option%3D";
261667
 
261667
@@ -2300,7 +2301,9 @@ CKHGetCoolKeyInfo(PK11SlotInfo *aSlot,Co
261667
     if(!memcmp( tokenInfo.manufacturerID,cac_manu_id,strlen(cac_manu_id ))) {
261667
         isACAC = 1;
261667
     } else if(!memcmp(tokenInfo.manufacturerID, piv_manu_id, strlen(piv_manu_id))) {
261667
-        isAPIV = 1;
261667
+        isAPIV = 1; 
261667
+    } else if(!memcmp(tokenInfo.manufacturerID, piv_manu_id_1, strlen(piv_manu_id_1))) {
261667
+	isAPIV = 1;
261667
     } else {
261667
         isACOOLKey = 1;
261667
     }
261667
diff -up ./esc/src/lib/coolkey-mgr/coolkey-api.cpp.fix10 ./esc/src/lib/coolkey-mgr/coolkey-api.cpp
261667
--- ./esc/src/lib/coolkey-mgr/coolkey-api.cpp.fix10	2020-12-02 15:47:00.673951320 -0800
261667
+++ ./esc/src/lib/coolkey-mgr/coolkey-api.cpp	2020-12-02 15:47:00.691951271 -0800
261667
@@ -17,6 +17,8 @@
261667
 
261667
 #include "coolkey-api.h"
261667
 #include "rhCoolKey.h"
261667
+#include <string>
261667
+
261667
 
261667
 static rhCoolKey *coolkey = NULL;
261667
 static const char * coolkeyDbusName = NULL;
261667
@@ -79,6 +81,54 @@ char *coolkey_get_phone_home(char *url)
261667
    } 
261667
 }
261667
 
261667
+/* get a string with all the certs detail for a token */
261667
+
261667
+char *coolkey_get_certs_info(int keyType, const char *keyID) {
261667
+
261667
+    string str_result;
261667
+    if (coolkey == NULL) {
261667
+	    return NULL;
261667
+    }
261667
+
261667
+    char *result = NULL;
261667
+    char **names = NULL;
261667
+    PRUint32 count = 0;
261667
+    HRESULT res =  coolkey->GetCoolKeyCertNicknames(keyType, keyID, &count, &names);
261667
+
261667
+    if(count > 0 && res == S_OK) {
261667
+        for(int i = 0 ; i < count ; i++) {
261667
+	    char *curName = names[i];
261667
+
261667
+	    if(curName) {
261667
+	        char *certDetail = NULL;
261667
+		str_result = str_result + curName + "\n" ;
261667
+	        res = coolkey->GetCoolKeyCertInfo(keyType, keyID, curName, &certDetail);
261667
+	        if(res == S_OK && certDetail != NULL) {
261667
+		    str_result = str_result + certDetail + "\n";
261667
+		    PL_strfree(certDetail);
261667
+		    certDetail = NULL;
261667
+	        }
261667
+	    }
261667
+	}
261667
+    }
261667
+
261667
+    if(str_result.c_str()) {
261667
+        result = PL_strdup((char *) str_result.c_str());
261667
+    }
261667
+
261667
+    for(int i = 0 ; i < count ; i++) {
261667
+        if(names[i]) {
261667
+	    PL_strfree(names[i]);
261667
+	    names[i] = NULL;
261667
+	}
261667
+    }
261667
+
261667
+    PR_Free(names);
261667
+    names = NULL;
261667
+
261667
+    return result;
261667
+}
261667
+
261667
 
261667
 /* get a block of data about a token in a structure format */
261667
 tokenInfo *coolkey_get_token_info(int keyType, const char *keyID) {
261667
diff -up ./esc/src/lib/coolkey-mgr/coolkey-api.h.fix10 ./esc/src/lib/coolkey-mgr/coolkey-api.h
261667
--- ./esc/src/lib/coolkey-mgr/coolkey-api.h.fix10	2020-12-02 15:47:00.673951320 -0800
261667
+++ ./esc/src/lib/coolkey-mgr/coolkey-api.h	2020-12-02 15:47:00.691951271 -0800
261667
@@ -43,6 +43,8 @@ void coolkey_init(const char *db_dir, co
261667
 void coolkey_destroy();
261667
 
261667
 char *coolkey_get_phone_home(char *url);
261667
+char *coolkey_get_certs_info(int keyType, const char *keyID);
261667
+
261667
 tokenInfo *coolkey_get_token_info(int keyType,const char *keyID);
261667
 void coolkey_free_token_info(tokenInfo *tInfo);
261667
 
261667
diff -up ./esc/src/lib/coolkey-mgr/coolkey-mgr.c.fix10 ./esc/src/lib/coolkey-mgr/coolkey-mgr.c
261667
--- ./esc/src/lib/coolkey-mgr/coolkey-mgr.c.fix10	2020-12-02 15:47:00.673951320 -0800
261667
+++ ./esc/src/lib/coolkey-mgr/coolkey-mgr.c	2020-12-02 15:47:00.691951271 -0800
261667
@@ -346,6 +346,36 @@ cleanup:
261667
 }
261667
 
261667
 
261667
+gchar*
261667
+coolkey_mgr_get_certs_info(CoolkeyMgr *self, CoolkeyToken* token) {
261667
+
261667
+    gchar *cuid = NULL;
261667
+    gchar *keyType = NULL;
261667
+    int keyTypeInt = 0;
261667
+    gchar *certInfo = NULL;
261667
+
261667
+    g_object_get(token,"key_type", &keyType,NULL);
261667
+    g_object_get(token,"cuid", &cuid, NULL);
261667
+
261667
+    if(keyType == NULL || cuid == NULL) {
261667
+       goto cleanup;
261667
+    }
261667
+
261667
+    keyTypeInt = atoi(keyType);
261667
+
261667
+    if(keyType == NULL || cuid == NULL) {
261667
+       goto cleanup;
261667
+    }
261667
+
261667
+    certInfo = coolkey_get_certs_info(keyTypeInt, cuid); 
261667
+
261667
+cleanup:
261667
+
261667
+    g_free (keyType);
261667
+    g_free (cuid);
261667
+    
261667
+    return  certInfo;
261667
+}
261667
 
261667
 void 
261667
 coolkey_mgr_get_token_info(CoolkeyMgr* self, CoolkeyToken* token) {
261667
diff -up ./esc/src/lib/coolkey-mgr/coolkey-mgr.h.fix10 ./esc/src/lib/coolkey-mgr/coolkey-mgr.h
261667
--- ./esc/src/lib/coolkey-mgr/coolkey-mgr.h.fix10	2020-12-02 15:47:00.673951320 -0800
261667
+++ ./esc/src/lib/coolkey-mgr/coolkey-mgr.h	2020-12-02 15:47:00.691951271 -0800
261667
@@ -46,6 +46,8 @@ int coolkey_mgr_cancel_token_operation(C
261667
 
261667
 void  coolkey_mgr_get_token_info(CoolkeyMgr* self, CoolkeyToken* token);
261667
 
261667
+gchar * coolkey_mgr_get_certs_info(CoolkeyMgr*self, CoolkeyToken* token);
261667
+
261667
 gchar * coolkey_mgr_phone_home(CoolkeyMgr* self, gchar *url);
261667
 
261667
 gchar * coolkey_mgr_speak (CoolkeyMgr* self, gchar *words);
261667
diff -up ./esc/src/lib/coolkey/NSSManager.cpp.fix10 ./esc/src/lib/coolkey/NSSManager.cpp
261667
--- ./esc/src/lib/coolkey/NSSManager.cpp.fix10	2020-12-02 15:47:00.680951301 -0800
261667
+++ ./esc/src/lib/coolkey/NSSManager.cpp	2020-12-02 15:47:00.691951271 -0800
261667
@@ -41,7 +41,7 @@
261667
 
261667
 #include <iostream>
261667
 #include <sstream>
261667
-
261667
+#include <algorithm>
261667
 #include "SlotUtils.h"
261667
 
261667
 static PRLogModuleInfo *coolKeyLogNSS = PR_NewLogModule("coolKeyNSS");
261667
@@ -314,7 +314,10 @@ NSSManager::GetKeyCertNicknames( const C
261667
             CERTCertificate *cert = node->cert;
261667
             if(cert)
261667
             {
261667
-                if(cert->slot != slot)
261667
+		char *certSlotName = PK11_GetSlotName(cert->slot);
261667
+		char *slotName = PK11_GetSlotName(slot);
261667
+
261667
+                if(strcmp(certSlotName, slotName))
261667
                 {
261667
                     CERT_RemoveCertListNode(node);
261667
                 }
261667
@@ -346,7 +349,10 @@ NSSManager::GetKeyCertNicknames( const C
261667
             PR_LOG( coolKeyLogNSS, PR_LOG_DEBUG, ("%s NSSManager::GetCertKeyNicknames name %s \n",GetTStamp(tBuff,56),curName));
261667
 
261667
             string str = curName;
261667
-            aStrings.push_back (str);
261667
+
261667
+	    if (find(aStrings.begin(), aStrings.end(), str) == aStrings.end()) {
261667
+                aStrings.push_back (str);
261667
+	    }
261667
         } 
261667
 
261667
         CERT_FreeNicknames(nicknames);
261667
@@ -691,6 +697,16 @@ HRESULT NSSManager::GetKeyCertInfo(const
261667
                         aCertInfo = issuedToCNStr + "\n" + issuerCNStr + "\n"
261667
                             + notBeforeStr + "\n" + notAfterStr + "\n" + serialStr ;
261667
                         PR_LOG( coolKeyLogNSS, PR_LOG_DEBUG, ("%s NSSManager::GetKeyCertInfo issuerCN %s issuedToCN %s \n",GetTStamp(tBuff,56),issuerCN, issuedToCN)); 
261667
+			
261667
+			if(nBefore) {
261667
+			    PORT_Free(nBefore);
261667
+			    nBefore  = NULL;
261667
+			}
261667
+
261667
+			if(nAfter) {
261667
+			    PORT_Free(nAfter);
261667
+			    nAfter = NULL;
261667
+			}
261667
 
261667
                         break;
261667
                     }