martinpaljak / GlobalPlatformPro

🌐 🔐 Manage applets and keys on JavaCard-s like a pro (via command line or from your Java project)
https://javacard.pro/globalplatform
GNU Lesser General Public License v3.0
683 stars 211 forks source link

gp.jar not working without libpcsclite.so symlink? #27

Closed lcosmin closed 8 years ago

lcosmin commented 9 years ago

I'm new to the whole smartcard business, so I might have missed something, but in Ubuntu 15.04 gp.jar is not working unless I explicitely create a symlink to libpcsclite.so.1.0.0 in /usr/lib64, like so:

$ java -jar gp.jar -list                                                                                  
$ sudo mkdir /usr/lib64 ; sudo ln -s /lib/x86_64-linux-gnu/libpcsclite.so.1.0.0 /usr/lib64/libpcsclite.so 
$ java -jar gp.jar -list                                                                                  
AID: A000000003000000 (|........|)                                                                        
     ISD OP_READY: Security Domain, Card lock, Card terminate, Default selected, CVM (PIN) management     

AID: D156000132000401 (|.V..2...|)                                                                        
     App SELECTABLE: (none)                                                                               

Using a compiled gp.jar from the current HEAD.

I guess there should be some sort of error message to explain what's going on, it took me a while to find this workaround...

martinpaljak commented 9 years ago

Generally speaking this is an issue with Java. I try to work around the problem with https://github.com/martinpaljak/apdu4j/blob/master/src/apdu4j/TerminalManager.java#L4, should add a FAQ entry and probably generalize the .so lookup even more. Good ideas and patches are most welcome.

lcosmin commented 9 years ago

It seems that git clone --recursive https://github.com/martinpaljak/GlobalPlatformPro doesn't checkout the latest commit from martinpalijak/apdu4j (the one which includes the correct libpcsclite.so.1 path for ubuntu 64bit), so that was the problem I was seeing before.

I cleaned up TerminalManager.java a bit (https://github.com/lcosmin/apdu4j/commit/c52cebe6f49053dc1ef07f98186a95bfde34b9a1) ; if it looks ok to you, I could send a pull request.

martinpaljak commented 9 years ago

Thanks, will have a look. I'm not really sure if just looping or trying trying to be "platform-aware" is the best choice, or a mix of both. But I'll leave this open until it gets fixed one way or another.

rcpao commented 8 years ago

I can confirm that the 'sudo mkdir /usr/lib64 ; sudo ln -s /lib/x86_64-linux-gnu/libpcsclite.so.1.0.0 /usr/lib64/libpcsclite.so' is required for Ubuntu 14.04.3 64-bit in order for gp.jar to work.

PS: In https://subgraph.com/sgos/documentation/smartcards/index.en.html, 'git clone https://github.com/martinpaljak/GlobalPlatform.git' requires adding '--recursive ' for apdu4j to be cloned as well: git clone --recursive https://github.com/martinpaljak/GlobalPlatform.git

martinpaljak commented 8 years ago

I can't vouch for out of date or otherwise incorrect information on other websites. The --recrusvie information has been there ever since it became required: https://github.com/martinpaljak/GlobalPlatformPro#get-it-now

martinpaljak commented 8 years ago

@lcosmin after giving it some thought, I'll not pull your change - it is a ugly hack but having it more verbosely for different platforms allows a more fine-grained control and also allows to print (possibly) useful hints to the user, like for FreeBSD. Updated the apdu4j reference and shall make a release shortly. If possible, please confirm that master works for you currently.