1 package org.apache.maven.wagon.providers.http;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.http.conn.ssl.TrustStrategy;
23
24 import java.security.cert.CertificateException;
25 import java.security.cert.CertificateExpiredException;
26 import java.security.cert.CertificateNotYetValidException;
27 import java.security.cert.X509Certificate;
28
29
30
31
32
33
34
35 public class RelaxedTrustStrategy
36 implements TrustStrategy
37 {
38 private final boolean ignoreSSLValidityDates;
39
40 public RelaxedTrustStrategy(boolean ignoreSSLValidityDates)
41 {
42 this.ignoreSSLValidityDates = ignoreSSLValidityDates;
43 }
44
45 public boolean isTrusted(X509Certificate[] certificates, String authType)
46 throws CertificateException
47 {
48 if ( ( certificates != null ) && ( certificates.length == 1 ) )
49 {
50 try
51 {
52 certificates[0].checkValidity();
53 }
54 catch ( CertificateExpiredException e )
55 {
56 if ( !ignoreSSLValidityDates )
57 {
58 throw e;
59 }
60 }
61 catch ( CertificateNotYetValidException e )
62 {
63 if ( !ignoreSSLValidityDates )
64 {
65 throw e;
66 }
67 }
68 return true;
69 }
70 else
71 {
72 return false;
73 }
74 }
75
76 }