From ccef1b59bc6cca89474eaddf7144972926281e29 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Wed, 10 May 2017 19:56:44 -0400 Subject: Clean up default location of PKCS #11 library. --- cryptech/py11/__init__.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'cryptech') diff --git a/cryptech/py11/__init__.py b/cryptech/py11/__init__.py index fb9af7e..1618a76 100644 --- a/cryptech/py11/__init__.py +++ b/cryptech/py11/__init__.py @@ -12,6 +12,15 @@ from .types import * from .constants import * from .attributes import * +import platform + +if platform.system() == "Darwin": + default_so_name = "/usr/local/lib/libcryptech-pkcs11.dylib" +elif platform.system() == "Linux": + default_so_name = "/usr/lib/libcryptech-pkcs11.so" +else: + default_so_name = "/usr/local/lib/libcryptech-pkcs11.so" + class PKCS11 (object): """ @@ -46,7 +55,7 @@ class PKCS11 (object): # Whether to use C_GetFunctionList() instead of dynamic link symbols. use_C_GetFunctionList = False - def __init__(self, so_name = "libpkcs11.so"): + def __init__(self, so_name = default_so_name): self.so_name = so_name self.so = CDLL(so_name) self.d = type("Dispatch", (object,), {})() -- cgit v1.2.3