Skip to content

Commit e0c8a0c

Browse files
author
gm2552
committed
More fixes to LDAP cert discovery.
Using new filters as a fallback method for looking up LDAP certs. Also updating expired test certificates.
1 parent 3150ee7 commit e0c8a0c

9 files changed

Lines changed: 22 additions & 2 deletions

File tree

src/main/java/org/nhindirect/stagent/cert/impl/LdapPublicCertUtilImpl.java

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
7171
*/
7272
public class LdapPublicCertUtilImpl implements LdapCertUtil{
7373

74-
private static final Log LOGGER = LogFactory.getFactory().getInstance(LdapPublicCertUtilImpl.class);
74+
private static final Log LOGGER = LogFactory.getLog(LdapPublicCertUtilImpl.class);
7575

7676
private static final String DEFAULT_LDAP_TIMEOUT = "5000";
7777
private static final String DEFAULT_LDAP_CONNECT_TIMEOUT = "10000";
@@ -134,9 +134,29 @@ public Collection<X509Certificate> ldapSearch(String subjectName){
134134

135135
NamingEnumeration<SearchResult> searchResult = ctx.search(
136136
dn,
137-
"(&(" + EMAIL_ATTRIBUTE + "=" + subjectName +")(|(userCertificate;binary=*)(userCertificate=*)))",
137+
EMAIL_ATTRIBUTE + "=" + subjectName,
138138
getDefaultSearchControls());
139139

140+
/*
141+
* Try again with slightly different filters. This is what is used by the NIST tooling. Some servers may not like this
142+
* syntax.
143+
*/
144+
145+
if (!(searchResult != null && searchResult.hasMore()))
146+
{
147+
try
148+
{
149+
searchResult = ctx.search(
150+
dn,
151+
"(&(" + EMAIL_ATTRIBUTE + "=" + subjectName +")(|(userCertificate;binary=*)(userCertificate=*)))",
152+
getDefaultSearchControls());
153+
}
154+
catch (Exception e)
155+
{
156+
LOGGER.warn("Exception when looking up LDAP certificates using alternative search filter: " + e.getMessage());
157+
}
158+
}
159+
140160
while (searchResult != null && searchResult.hasMore()) {
141161
final SearchResult certEntry = searchResult.nextElement();
142162
if (certEntry != null) {
0 Bytes
Binary file not shown.
1 Byte
Binary file not shown.
13 Bytes
Binary file not shown.
8 Bytes
Binary file not shown.
1 Byte
Binary file not shown.
13 Bytes
Binary file not shown.
6 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)