错误信息1

  1. Root exception is javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
  • 找不到所请求目标的有效证书路径
  1. Root exception is javax.net.ssl.SSLException: Couldn't kickstart handshaking
  • 无法启动握手

分析1

AD域修改密码需要使用ldaps协议修改,普通的389端口无法修改密码,一般ldaps的默认使用端口是636。 使用ldaps从外部连接时,必须要有证书,需要向服务端索要证书,导入到本地jdk中。

解决1

错误信息2

  1. Root exception is java.net.SocketException: Connection or outbound has closed
  • 连接或出站已关闭

分析2

如果你使用的版本低于jdk1.8.0.181,就不会出现这个错误。 这是因为oracle官方在jdk1.8.0.181中进行了升级,内容如下: alt

官网记录地址

大致内容是说:为了提高LDAP(secureldap over TLS)连接的健壮性,默认情况下启用了端点识别算法。在某些情况下,以前能够成功连接到LDAPS服务器的某些应用程序可能不再能够这样做。如果这些应用程序认为合适,可以使用新的系统属性禁用端点标识:com.sun.jndi.ldap.object.disableEndpointIdentification。定义此系统属性(或将其设置为true)以禁用端点识别算法。

解决2

  • 以下两种方式都可
  1. 在项目启动类中禁用端点识别算法(在项目启动的时候设置系统参数)
System.setProperty("com.sun.jndi.ldap.object.disableEndpointIdentification","true");

alt

  1. 设置项目启动参数
-Dcom.sun.jndi.ldap.object.disableEndpointIdentification=true

alt