- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我创建了一个自定义 SSLSocketFactory 类并将其设置如下
ldapEnv.put(Context.SECURITY_PROTOCOL, "ssl");
ldapEnv.put(FACTORY_SOCKET, socketFactoryClass);
LdapContext ldapContext = new InitialLdapContext(ldapEnv, null);
从 Eclipse Dev Environment 运行时工作正常,并从命令提示符将其作为 Jar 文件运行。但是当我将它包装在服务包装器中并将其作为 Windows 服务启动时,它不起作用。我得到以下异常,
javax.naming.CommunicationException: 192.168.100.22:636 [Root exception is java.lang.ClassNotFoundException: com/testing/diraccess/service/ActiveDirectory$TestSSLFactory]
at com.sun.jndi.ldap.Connection.<init>(Unknown Source)
at com.sun.jndi.ldap.LdapClient.<init>(Unknown Source)
at com.sun.jndi.ldap.LdapClient.getInstance(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.connect(Unknown Source)
at com.sun.jndi.ldap.LdapCtx.<init>(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(Unknown Source)
at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(Unknown Source)
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.init(Unknown Source)
at javax.naming.ldap.InitialLdapContext.<init>(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com/testing/diraccess/service/ActiveDirectory$TestSSLFactory
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at com.sun.jndi.ldap.VersionHelper12.loadClass(Unknown Source)
at com.sun.jndi.ldap.Connection.createSocket(Unknown Source)
... 35 more
有什么帮助吗???
最佳答案
似乎这个问题可能是由于 JNDI 依赖于设置正确的线程上下文类加载器(管理员可能没有这样做),这是必需的,因为 JNDI 类由加载器层次结构和该类加载器基础上的类加载器加载将找不到应用程序/容器类加载器加载的类。因此 JNDI 提供了一个钩子(Hook)来通过线程上下文类加载器加载这些类。
看看这是否有效,
// Save the current thread context class loader
ClassLoader currentCL = Thread.currentThread().getContextClassLoader();
// Set the context class loader to the one we know for sure loaded classes inside configstore-core.jar
Thread.currentThread().setContextClassLoader(OmParticipant.class.getClassLoader());
// Invoke the jndi related code that will internally try to load our socket factory impl
...
//restore the original class loader
Thread.currentThread().setContextClassLoader(currentCL );
关于java - 使用自定义 SSLSocketFactory 时出现 ClassNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8253958/
在我的项目中,我使用的是 java 8,并且在 mu pom.xml 以及我的 eclipse 中配置了相同的配置。但是每当我尝试通过 mvn install 编译我的代码时,它就会抛出以下错误。我也
我需要创建一个 javax.net.ssl.SSLSocketFactory 来建立 TLS 连接但忽略服务器证书的验证。不适用于 HTTP 协议(protocol)。我知道这不是正确的做法,但我需要
我有一个协议(protocol),其中有一个升级到 SSL/TLS 的普通普通套接字。我需要能够控制处理 SSL 握手的超时以及其他参数,例如允许的协议(protocol)版本。 (例如关闭 SSLv
我正在尝试创建自己的 javax.net.ssl.SSLSocketFactory 实现,为了捕获所有由第三方库发送的 HTTP/SSL 请求,并记录它们。这是在该库中调用工厂的方式(它是 commo
我有一个 SSLSocketFactory 和一个 TrustManagerFactory,如下所示: TrustManagerFactory tmf = TrustManagerFactory.ge
我正在构建一个客户端应用程序,它将通过 soap 消息连接到第三方服务器。我正在使用在 JBoss 4.2.3 上运行的 jax-ws 2.1.9 和 jdk 1.6_18。 问题本身是配置为仅用于测
我试图绕过对我的连接的 SSL 检查 - SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefa
我有一个实用程序 SSLSocketFactory 类,它基本上允许您切换是否要信任所有证书和/或由于 JDK 错误而关闭 Diffie-Hellman。我最近添加了提供您自己的 SSLSocketF
根据 http://hc.apache.org/httpcomponents-client-ga/httpclient/examples/org/apache/http/examples/client
java中的SSLSocketFactory类在使用HttpsURLConnection时起到什么作用? java文档没有太大帮助。 是否有任何方法可以将 keystore 和信任库与 sslsock
在我们的产品中,我们使用 SSLSocketFactory 创建到服务器的 SSLSocket。在创建到服务器的套接字时,我们根据产品配置使用两种方法之一: (1) 我们创建一个标准套接字,然后将其包
Spring-Ldap 1.3.1 为了使用 TLS 测试 spring-ldap,我创建了一个接受所有证书的 CustomSSLSocketFactory 类(我知道这个的安全问题)。 运行测试结果
在我们的应用程序中,当应用程序与服务器通信时,我会额外检查证书(公钥固定)(针对 MITMA)。为了与服务器通信,我使用 HttpClient。另外我在生产中有一些代理服务器,所以我需要使用 SNI。
我当前的 TCP 客户端正在使用 org.apache.http.conn.ssl.SSLSocketFactory 构建套接字我正在迁移到 import javax.net.ssl.SSLSocke
我有一台带有自签名证书的服务器。我已经在我的计算机上使用 keytool 导入它并使用 -Djavax.net.ssl.trustStore=blabla 编译参数。当我尝试运行以下代码时: SSLS
我的代码在这里: SSLContext sslContext = SSLContext.getInstance("TLS"); sslContext.init(null, getAllCerts(),
在 WebSphere 中部署 Spring Boot 应用程序。由于它们的 SSL 配置,我们需要明确指定 SSLSocketFactory 以确保应用程序使用 WebSphere 证书而不是默认的
我正在使用 OkHttp,我需要忽略 SSL 错误以进行应用程序调试。这曾经在 Java 8 中有效。 final TrustManager[] trustAllCerts = new TrustMa
SSLSocketFactory 提供 getDefaultCipherSuites(默认情况下在套接字上启用的密码)和 getSupportedCipherSuites(如果需要,可以启用的密码)。
我创建了一个自定义 SSLSocketFactory 类并将其设置如下 ldapEnv.put(Context.SECURITY_PROTOCOL, "ssl"); ldapEnv.put(FACTO
我是一名优秀的程序员,十分优秀!