Hi there,
I am trying to install encripted comunication with ApacheDS starting a TLS
connection. You can find hereinafter the code i used to set the TLS connection:
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.ldap.LdapCtxFactory");
properties.put(Context.PROVIDER_URL, spd.getLDAPUrl());
properties.put(Context.SECURITY_PRINCIPAL,
spd.getLDAPSecurityPrincipal());
properties.put(Context.SECURITY_CREDENTIALS,
spd.getLDAPSecurityCredentials());
LdapContext context = null;
StartTlsResponse tls = null;
try {
context = new InitialLdapContext(properties,null);
Attributes attrs = context.getAttributes(
spd.getLDAPUrl(), new
String[]{"supportedcontrol"});
System.out.println("size :" + attrs.size());
System.out.println(attrs);
// Start TLS
tls =
(StartTlsResponse) context.extendedOperation(new
StartTlsRequest());
SSLSession sess = tls.negotiate();
etc, etc
During the negotiation (SSLSession sess = tls.negotiate();) the app raise the
following error:
PKIX path building failed:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find
valid certification path to requested target
I set the startTLS connection on the server side. Then, by means of the keytool
utility, I export a certificate from the keystore used by ApacheDS and add this
certificate to the JVM. In the following the two certificates on the client
side (JVM) and on the Server side (Apacheds)
Server side:
Tipo keystore: JKS
Provider keystore: SUN
Il keystore contiene 1 voce
Nome alias: dem
Data di creazione: 5-apr-2017
Tipo di voce: PrivateKeyEntry
Lunghezza catena certificati: 1
Certificato[1]:
Proprietario: CN=localhost, OU=ApacheDS, O=ASF, C=US
Autorità emittente: CN=localhost, OU=ApacheDS, O=ASF, C=US
Numero di serie: 6b297e82
Valido da: Wed Apr 05 11:12:11 CEST 2017 a: Fri Apr 05 11:12:11 CEST 2019
Impronte digitali certificato:
MD5: 21:7B:90:97:3F:FB:25:1B:1B:3C:00:E4:0D:6F:1D:87
SHA1: 5D:ED:7F:FD:E8:10:B7:18:F9:E8:B9:19:60:5B:4B:BA:8D:56:67:29
SHA256:
21:75:55:C6:A1:5A:A0:7D:88:73:7C:C6:6B:D2:FC:3A:18:4A:98:54:91:E5:69:6A:86:E3:D6:69:5F:33:34:16
Nome algoritmo firma: SHA256withRSA
Versione: 3
Estensioni:
#1: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: 34 13 78 51 0E 73 20 06 58 BE 94 2E 94 53 77 42 4.xQ.s .X....SwB
0010: 9B E0 05 35 ...5
]
]
On the client side, instead:
Nome alias: dem
Data di creazione: 5-apr-2017
Tipo di voce: trustedCertEntry
Proprietario: CN=localhost, OU=ApacheDS, O=ASF, C=US
Autorità emittente: CN=localhost, OU=ApacheDS, O=ASF, C=US
Numero di serie: 6b297e82
Valido da: Wed Apr 05 11:12:11 CEST 2017 a: Fri Apr 05 11:12:11 CEST 2019
Impronte digitali certificato:
MD5: 21:7B:90:97:3F:FB:25:1B:1B:3C:00:E4:0D:6F:1D:87
SHA1: 5D:ED:7F:FD:E8:10:B7:18:F9:E8:B9:19:60:5B:4B:BA:8D:56:67:29
SHA256:
21:75:55:C6:A1:5A:A0:7D:88:73:7C:C6:6B:D2:FC:3A:18:4A:98:54:91:E5:69:6A:86:E3:D6:69:5F:33:34:16
Nome algoritmo firma: SHA256withRSA
Versione: 3
Estensioni:
#1: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: 34 13 78 51 0E 73 20 06 58 BE 94 2E 94 53 77 42 4.xQ.s .X....SwB
0010: 9B E0 05 35 ...5
]
]
Please help me. I am struggling with this problem for a long time. In past I
fixed this problem, but now, using the same procedure, it does not work.
Many thancks in advance,
Pasquale
Il presente messaggio e-mail e ogni suo allegato devono intendersi indirizzati
esclusivamente al destinatario indicato e considerarsi dal contenuto
strettamente riservato e confidenziale. Se non siete l'effettivo destinatario o
avete ricevuto il messaggio e-mail per errore, siete pregati di avvertire
immediatamente il mittente e di cancellare il suddetto messaggio e ogni suo
allegato dal vostro sistema informatico. Qualsiasi utilizzo, diffusione, copia
o archiviazione del presente messaggio da parte di chi non ne è il destinatario
è strettamente proibito e può dar luogo a responsabilità di carattere civile e
penale punibili ai sensi di legge.
Questa e-mail ha valore legale solo se firmata digitalmente ai sensi della
normativa vigente.
________________________________
The contents of this email message and any attachments are intended solely for
the addressee(s) and contain confidential and/or privileged information.
If you are not the intended recipient of this message, or if this message has
been addressed to you in error, please immediately notify the sender and then
delete this message and any attachments from your system. If you are not the
intended recipient, you are hereby notified that any use, dissemination,
copying, or storage of this message or its attachments is strictly prohibited.
Unauthorized disclosure and/or use of information contained in this email
message may result in civil and criminal liability. “
This e-mail has legal value according to the applicable laws only if it is
digitally signed by the sender