diff --git a/src/net/java/sip/communicator/impl/certificate/CertificateServiceImpl.java b/src/net/java/sip/communicator/impl/certificate/CertificateServiceImpl.java index 6afa10e4a..eca56869f 100644 --- a/src/net/java/sip/communicator/impl/certificate/CertificateServiceImpl.java +++ b/src/net/java/sip/communicator/impl/certificate/CertificateServiceImpl.java @@ -8,6 +8,7 @@ import java.beans.*; import java.io.*; +import java.lang.reflect.*; import java.net.*; import java.security.*; import java.security.KeyStore.*; @@ -47,8 +48,11 @@ public class CertificateServiceImpl new LinkedList() { { - add(new KeyStoreType("PKCS11", new String[] - { ".dll", ".so" }, false)); + if(!OSUtils.IS_WINDOWS64) + { + add(new KeyStoreType("PKCS11", new String[] + { ".dll", ".so" }, false)); + } add(new KeyStoreType("PKCS12", new String[] { ".p12", ".pfx" }, true)); add(new KeyStoreType(KeyStore.getDefaultType(), new String[] @@ -340,10 +344,20 @@ private Builder loadKeyStore(final CertificateConfigEntry entry) { String config = "name=" + f.getName() + "\nlibrary=" + f.getAbsoluteFile(); - Provider p = - new sun.security.pkcs11.SunPKCS11(new ByteArrayInputStream( - config.getBytes())); - Security.insertProviderAt(p, 0); + try + { + Class pkcs11c = Class.forName("sun.security.pkcs11.SunPKCS11"); + Constructor c = pkcs11c.getConstructor(InputStream.class); + Provider p = (Provider)c.newInstance( + new ByteArrayInputStream(config.getBytes()) + ); + Security.insertProviderAt(p, 0); + } + catch (Exception e) + { + logger.error("Tried to access the PKCS11 provider on an " + + "unsupported platform or the load failed", e); + } } KeyStore.Builder ksBuilder = KeyStore.Builder.newInstance(kt.getName(), null, f,