Problem with Big Sur 11.0.1 and PC/SC library
Asked Answered
T

1

5

I have a problem with the newest version of macOS (BigSur 11.0.1) and the library PC/SC; before BigSur the program the uses the library worked fine but after the update isn't working anymore. I am using the java version 1.8.0_271

In the code, I use the method TerminalFactory.getDefaultType() to get the default type of Terminal Factory. Before the update I was receiving "PC/SC" but after the update I am receiving None.

If I want force to connect to an instance with this line

TerminalFactory factory = TerminalFactory.getInstance("PC/SC", null);

It will return the following error:

java.security.NoSuchAlgorithmException: Error constructing implementation (algorithm: PC/SC, provider: SunPCSC, class: sun.security.smartcardio.SunPCSC$Factory)
at java.security.Provider$Service.newInstance(Provider.java:1711)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:243)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:190)
at javax.smartcardio.TerminalFactory.getInstance(TerminalFactory.java:245)
at prueba.Prueba.isConnected(Prueba.java:165)
at prueba.Prueba.main(Prueba.java:63)
Caused by: java.lang.UnsupportedOperationException: PC/SC not available on this platform
at sun.security.smartcardio.PCSC.checkAvailable(PCSC.java:46)
at sun.security.smartcardio.SunPCSC$Factory.<init>(SunPCSC.java:59)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.security.Provider$Service.newInstance(Provider.java:1703)
... 5 more
Caused by: java.io.IOException: No PC/SC library found on this system
at sun.security.smartcardio.PlatformPCSC.getLibraryName(PlatformPCSC.java:122)
at sun.security.smartcardio.PlatformPCSC.access$000(PlatformPCSC.java:43)
at sun.security.smartcardio.PlatformPCSC$1.run(PlatformPCSC.java:64)
at sun.security.smartcardio.PlatformPCSC$1.run(PlatformPCSC.java:60)
at java.security.AccessController.doPrivileged(Native Method)
at sun.security.smartcardio.PlatformPCSC.<clinit>(PlatformPCSC.java:60)
at sun.security.smartcardio.SunPCSC$Factory.<init>(SunPCSC.java:59)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.security.Provider$Service.newInstance(Provider.java:1703)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:243)
at sun.security.jca.GetInstance.getInstance(GetInstance.java:190)
at javax.smartcardio.TerminalFactory.getInstance(TerminalFactory.java:245)
at javax.smartcardio.TerminalFactory.<clinit>(TerminalFactory.java:106)
at prueba.Prueba.isConnected(Prueba.java:164)
... 1 more
entro isConnected--2
Exception in thread "main" java.lang.NullPointerException
at prueba.Prueba.isConnected(Prueba.java:173)
at prueba.Prueba.main(Prueba.java:63)

I found that Big Sur eliminates the library PC/SC and it is no possible to install it.

I don´t know if there is someone with the same error or someone that has already fix it.

Thanks for the help.

Totemism answered 24/11, 2020 at 22:45 Comment(2)
Best I could find: developer.apple.com/forums/thread/657267Charybdis
@JorgeCampos Yes, I've already seen this post, but I don't use the filesystem dlopen(3) that is explain in the forum.Totemism
S
8

Because of the changes in macOS Big Sur, Java PC/SC implementation no longer works correctly: https://bugs.openjdk.java.net/browse/JDK-8255877

The workaround is to set the system property: sun.security.smartcardio.library=/System/Library/Frameworks/PCSC.framework/Versions/Current/PCSC

before trying to use TerminalFactory.

Seldun answered 29/11, 2020 at 17:3 Comment(7)
Thank you very much! Your answer saved me a lot of time.Aboriginal
can you explain the solution, because it does not work for me...do you set the system prop in the console ?Trilinear
in fact the PCSC exec exist on my pro with sierra but not on air with bigsurTrilinear
@Trilinear either with java -Dproperty=value option or System.setProperty() in a static initializer.Seldun
fyi, java -Dproperty=value in the bash is working !Trilinear
System.setProperty("sun.security.smartcardio.library", "/System/Library/Frameworks/PCSC.framework/Versions/Current/PCSC"); This work for me!Deoxygenate
Adding -Dsun.security.smartcardio.library=/System/Library/Frameworks/PCSC.framework/PCSC works on BigSur and JDK 14Phillips

© 2022 - 2024 — McMap. All rights reserved.