Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update HTTP-TPC to ignore whether certificates have allowed namespace #68

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions src/main/java/org/italiangrid/storm/webdav/spring/AppConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;

import javax.net.ssl.KeyManager;
import javax.net.ssl.SSLContext;
Expand Down Expand Up @@ -200,25 +201,31 @@ HealthCheckRegistry healthCheckRegistry() {

@Bean
X509CertChainValidatorExt canlCertChainValidator(ServiceConfiguration configuration) {
return canlCertChainCustomValidator(configuration,
b -> b.namespaceChecks(NamespaceCheckingMode.EUGRIDPMA_AND_GLOBUS_REQUIRE));
}

private X509CertChainValidatorExt canlCertChainCustomValidator(ServiceConfiguration configuration,
Function<CertificateValidatorBuilder,CertificateValidatorBuilder> customiseValidatorBuilder) {

CANLListener l = new org.italiangrid.storm.webdav.server.util.CANLListener();
CertificateValidatorBuilder builder = new CertificateValidatorBuilder();

long refreshInterval =
TimeUnit.SECONDS.toMillis(configuration.getTrustAnchorsRefreshIntervalInSeconds());

return builder.namespaceChecks(NamespaceCheckingMode.EUGRIDPMA_AND_GLOBUS_REQUIRE)
CertificateValidatorBuilder builder = new CertificateValidatorBuilder()
.crlChecks(CrlCheckingMode.IF_VALID)
.ocspChecks(OCSPCheckingMode.IGNORE)
.lazyAnchorsLoading(false)
.storeUpdateListener(l)
.validationErrorListener(l)
.trustAnchorsDir(configuration.getTrustAnchorsDir())
.trustAnchorsUpdateInterval(refreshInterval)
.build();
.trustAnchorsUpdateInterval(refreshInterval);

return customiseValidatorBuilder.apply(builder).build();
}


@Bean
PathResolver pathResolver(ServiceConfiguration conf) {
return new DefaultPathResolver(storageAreaConfiguration(conf));
Expand All @@ -241,7 +248,9 @@ HttpClientConnectionManager tpcClientConnectionManager(ThirdPartyCopyProperties
NoSuchAlgorithmException, NoSuchProviderException, KeyManagementException {
PEMCredential serviceCredential = serviceCredential(conf);

SSLTrustManager tm = new SSLTrustManager(canlCertChainValidator(conf));
X509CertChainValidatorExt validator = canlCertChainCustomValidator(conf,
b -> b.namespaceChecks(NamespaceCheckingMode.IGNORE));
SSLTrustManager tm = new SSLTrustManager(validator);

SSLContext ctx;

Expand Down