Skip to content

Commit 69a7985

Browse files
authored
Merge pull request phax#308 from beth-soptim/sig_subject_contraints
Support setting the certificate issuer constraints for WSS4J phax#307
2 parents 6848794 + aad83f0 commit 69a7985

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

phase4-lib/src/main/java/com/helger/phase4/crypto/IAS4CryptoFactory.java

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616
*/
1717
package com.helger.phase4.crypto;
1818

19-
import java.security.KeyStore;
19+
import org.apache.wss4j.common.crypto.Crypto;
2020

2121
import javax.annotation.Nonnull;
2222
import javax.annotation.Nullable;
23-
24-
import org.apache.wss4j.common.crypto.Crypto;
23+
import java.security.KeyStore;
24+
import java.util.Collection;
25+
import java.util.regex.Pattern;
2526

2627
/**
2728
* The basic phase4 crypto interface.
@@ -102,4 +103,17 @@ default String getKeyPasswordPerAlias (@Nullable final String sSearchKeyAlias)
102103
*/
103104
@Nullable
104105
KeyStore getTrustStore ();
106+
107+
/**
108+
* Returns the signature subject certificate constraints as regular expressions
109+
*
110+
* @return The signature subject certificate constraints as regular expressions or <code>null</code> if no checks should be performed.
111+
* @since 3.0.7
112+
*/
113+
@Nullable
114+
default Collection<Pattern> getSignatureSubjectCertConstraints ()
115+
{
116+
return null;
117+
}
118+
105119
}

phase4-lib/src/main/java/com/helger/phase4/incoming/soap/SoapHeaderElementProcessorWSS4J.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
import java.security.Provider;
2222
import java.security.cert.X509Certificate;
2323
import java.util.Arrays;
24+
import java.util.Collection;
2425
import java.util.List;
2526
import java.util.Locale;
2627
import java.util.function.Supplier;
28+
import java.util.regex.Pattern;
2729

2830
import javax.annotation.Nonnull;
2931
import javax.annotation.Nullable;
@@ -195,11 +197,11 @@ private ESuccess _verifyAndDecrypt (@Nonnull final Document aSOAPDoc,
195197
if (false)
196198
aRequestData.setEnableRevocation (true);
197199

198-
// TODO workaround to avoid the warning (if CRL checking is enabled)
199-
// No Subject DN Certificate Constraints were defined. This could be a
200-
// security issue
201-
if (false)
202-
aRequestData.setSubjectCertConstraints (new CommonsArrayList <> (RegExCache.getPattern (".*")));
200+
Collection<Pattern> signatureSubjectCertConstraints = m_aCryptoFactorySign.getSignatureSubjectCertConstraints();
201+
if (signatureSubjectCertConstraints != null)
202+
{
203+
aRequestData.setSubjectCertConstraints (signatureSubjectCertConstraints);
204+
}
203205

204206
if (m_aDecryptParameterModifier != null)
205207
{

0 commit comments

Comments
 (0)