Trying to us pkcs11 getModuleSlots()


(Stevennobile) #1

I am attempting to create a simple test where some content_script runs on a page a create a timer that then goes to some background script which uses the pkcs11 API to determine is there is a card in the smart card reader. Here is what is have. When I run it, the outputs are test 1 test 3 ERROR: NO SUCH PKCS#11 MODULE ActiveClientModule.
{

"manifest_version": 2,
"name": "CACListener",
"version": "1.0",

"description": "Adds a polling Listener to the carder reader slot",

"browser_specific_settings": 
{
	"gecko": 
	{
		"id": "cacListener@taa.com",
		"strict_min_version": "42.0"
	}
},

"permissions": 
[
	"pkcs11"
],
	
"icons": 
{
	"48": "icons/border-48.png"
},

"background": 
{
	"scripts": ["background.js"]
},

"content_scripts": 
[
	{
		"matches": ["*://*/taa/*"],
		"js": ["CACListener.js"]
	}
]

}

pkcs11.json
{
“name”: “ActiveClientModule”,
“description”: “json referenceing the acpkcs211.dll”,
“type”: “pkcs11”,
“path”: “C:\Program Files\HID Global\ActivClient\acpkcs211.dll”,
“allowed_extensions”: [“cacListener@taa.com”]
}

CACListener.js
var lastStatus = “Insert”;
var currentStatus = “Insert”;

setTimeout(checkReaderStatus, 1000);
//alert("0");
function checkReaderStatus()
{
	try
	{
	if (!navigator.appName.toUpperCase().substring(0, 9) == "MICROSOFT");
	{	
		var response = browser.runtime.sendMessage({content: "Check Reader"});
		
		setTimeout(checkReaderStatus, 1000);
	}
	
	}
	catch(e)
	{
		alert(e);
	}
}

function onSmartCardInsert() 
{
	if (isQuick) 
	{
		window.location = "QCAC1.jsp";
	} 
	else 
	{
		window.location.href = "index1.jsp";
	}
}

function onSmartCardRemove() 
{
	var inputs = document.getElementsByTagName("input");
	for (var i = 0; i < inputs.length; i++) 
	{
		inputs[i].disabled = true;
	}
	var selects = document.getElementsByTagName("select");
	for (var i = 0; i < selects.length; i++) 
	{
		selects[i].disabled = true;
	}
	var textareas = document.getElementsByTagName("textarea");
	for (var i = 0; i < textareas.length; i++) 
	{
		textareas[i].disabled = true;
	}
	var buttons = document.getElementsByTagName("button");
	for (var i = 0; i < buttons.length; i++) 
	{
		buttons[i].disabled = true;
	}
}

background.js
browser.runtime.onMessage.addListener(handleMessage);

function handleMessage(request) 
{
		console.log("test1");
		var slots = browser.pkcs11.getModuleSlots("ActiveClientModule");
		var arrayLength = slots.length;
		for (var i = 0; i < arrayLength; i++) 
		{
			console.log("test 2");
		}
		
		console.log("test 3");
}

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Mozilla\PKCS11Modules
deault=C:\Development_Projects\AFTAA\aftaa-maint\aftaa-14.1.14\workspace\taaStruts\WebRoot\common\webExtensions\CACListener\pkcs11.json


(Martin Giger) #2

Pretty sure this is supposed to exactly match the extension ID, so

"allowed_extensions": ["cacListener@taa.com"]

(Stevennobile) #3

Sorry - It does. That was copy paste error while writing this post.
{
“name”: “ActiveClientModule”,
“description”: “json referenceing the acpkcs211.dll”,
“type”: “pkcs11”,
“path”: “C:\Program Files\HID Global\ActivClient\acpkcs211.dll”,
“allowed_extensions”: [“cacListener@taa.com”]
}

Still not working. I’ll fix that.