Active Directory 证书导入成功,但 LDAP 身份验证仍然失败

Active Directory 证书导入成功,但 LDAP 身份验证仍然失败

我很难找到这个问题的根源。我们使用 LDAP 跨多个服务进行身份验证,包括 confluence、bamboo、sonar、gerrit 等。我们的 LDAP 服务提供商是 Active Directory。我已设置所有服务并使用 LDAP 和 JDK 1.6.0_24。没有身份验证问题。

最近,我们尝试升级到 JDK 的最新版本 1.6.0_31。我针对旧 JDK 重复了相同的步骤,以从 Active Directory 导入 LDAP 受信任证书:

Windows

Navigate to the directory in which Java is installed. It's probably called something like C:\Program Files\Java\jdk1.5.0_12.

Run the command below, where server-certificate.crt is the name of the file from your directory server:

keytool -import -keystore .\jre\lib\security\cacerts -file server-certificate.crt

keytool will prompt you for a password. The default keystore password is changeit.

When prompted Trust this certificate? [no]: enter yes to confirm the key import:
Enter keystore password:  changeit
Owner: CN=ad01, C=US
Issuer: CN=ad01, C=US
Serial number: 15563d6677a4e9e4582d8a84be683f9
Valid from: Tue Aug 21 01:10:46 ACT 2007 until: Tue Aug 21 01:13:59 ACT 2012
Certificate fingerprints:
         MD5:  D6:56:F0:23:16:E3:62:2C:6F:8A:0A:37:30:A1:84:BE
         SHA1: 73:73:4E:A6:A0:D1:4E:F4:F3:CD:CE:BE:96:80:35:D2:B4:7C:79:C1
Trust this certificate? [no]:  yes
Certificate was added to keystore

指示来自:

http://confluence.atlassian.com/display/DOC/Configuring+an+SSL+Connection+to+Active+Directory

我将 JAVA_HOME 和 PATH 变量设置为新的 JDK:

JAVA_HOME=C:\Program Files\Java\jdk1.6.0_31
PATH=%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;c:\development\ant\bin;C:\development\tools\SysinternalsSuite;C:\Program Files\Java\jdk1.6.0_31\bin

当我启动任何一项现有服务时,我的日志会加载 LDAP 身份验证错误:

原因:sun.security.validator.ValidatorException:PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效认证路径

所有服务都出现相同的错误。显然路径和导入的证书出了问题。我使用 keytool 检查以确保我的 LDAP 证书“mykey”已正确导入。它显示它已成功导入为受信任的证书:

C:\Program Files\Java\jdk1.6.0_31\jre\lib\security>keytool -list -keystore cac
ts
Enter keystore password:

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 77 entries

digicertassuredidrootca, Jan 7, 2008, trustedCertEntry,
Certificate fingerprint (MD5): 87:CE:0B:7B:2A:0E:49:00:E1:58:71:9B:37:A8:93:72
trustcenterclass2caii, Jan 7, 2008, trustedCertEntry,
Certificate fingerprint (MD5): CE:78:33:5C:59:78:01:6E:18:EA:B9:36:A0:B9:2E:23
thawtepremiumserverca, Dec 2, 2009, trustedCertEntry,
Certificate fingerprint (MD5): A6:6B:60:90:23:9B:3F:2D:BB:98:6F:D6:A7:19:0D:46
swisssignplatinumg2ca, Aug 13, 2008, trustedCertEntry,
Certificate fingerprint (MD5): C9:98:27:77:28:1E:3D:0E:15:3C:84:00:B8:85:03:E6
swisssignsilverg2ca, Aug 13, 2008, trustedCertEntry,
Certificate fingerprint (MD5): E0:06:A1:C9:7D:CF:C9:FC:0D:C0:56:75:96:D8:62:13
thawteserverca, Dec 2, 2009, trustedCertEntry,
Certificate fingerprint (MD5): EE:FE:61:69:65:6E:F8:9C:C6:2A:F4:D7:2B:63:EF:A2
equifaxsecureebusinessca1, Jul 18, 2003, trustedCertEntry,
Certificate fingerprint (MD5): 64:9C:EF:2E:44:FC:C6:8F:52:07:D0:51:73:8F:CB:3D
utnuserfirstclientauthemailca, May 2, 2006, trustedCertEntry,
Certificate fingerprint (MD5): D7:34:3D:EF:1D:27:09:28:E1:31:02:5B:13:2B:DD:F7
thawtepersonalfreemailca, Dec 2, 2009, trustedCertEntry,
Certificate fingerprint (MD5): 53:4B:1D:17:58:58:1A:30:A1:90:F8:6E:5C:F2:CF:65
entrustevca, Apr 28, 2009, trustedCertEntry,
Certificate fingerprint (MD5): D6:A5:C3:ED:5D:DD:3E:00:C1:3D:87:92:1F:1D:3F:E4
utnuserfirsthardwareca, May 2, 2006, trustedCertEntry,
Certificate fingerprint (MD5): 4C:56:41:E5:0D:BB:2B:E8:CA:A3:ED:18:08:AD:43:39
certumca, Feb 10, 2009, trustedCertEntry,
Certificate fingerprint (MD5): 2C:8F:9F:66:1D:18:90:B1:47:26:9D:8E:86:82:8C:A9
entrustrootcag2, Jun 22, 2010, trustedCertEntry,
Certificate fingerprint (MD5): 4B:E2:C9:91:96:65:0C:F4:0E:5A:93:92:A0:0A:FE:B2
addtrustclass1ca, May 2, 2006, trustedCertEntry,
Certificate fingerprint (MD5): 1E:42:95:02:33:92:6B:B9:5F:C0:7F:DA:D6:B2:4B:FC
equifaxsecureca, Jul 18, 2003, trustedCertEntry,
Certificate fingerprint (MD5): 67:CB:9D:C0:13:24:8A:82:9B:B2:17:1E:D1:1B:EC:D4
quovadisrootca3, Jun 9, 2009, trustedCertEntry,
Certificate fingerprint (MD5): 31:85:3C:62:94:97:63:B9:AA:FD:89:4E:AF:6F:E0:CF
quovadisrootca2, Jun 9, 2009, trustedCertEntry,
Certificate fingerprint (MD5): XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX
mykey, Apr 25, 2012, trustedCertEntry,
...

最新的 1.6 JDK 中是否有某些更改导致默认证书验证失效?为什么此过程在 24 版本中有效,而在 31 版本中却失败了?

非常感谢您的帮助。谢谢!

答案1

哇,已经搞清楚了。显然,JDK 安装程序将额外的 JRE 安装部署到 C:\Program Files\Java\jre6,其中包含最新的 jre 版本。无论 JAVA_HOME 和 PATH 的设置如何,此目录都在使用中。我必须将我的证书导入到 C:\Program Files\Java\jre6\lib\security\cacerts,然后一切又开始正常工作了。

相关内容