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