Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
Openfire
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Openfire
Commits
99930932
Commit
99930932
authored
Dec 01, 2015
by
Guus der Kinderen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not use CRLs, Add logging, and default to BC provider.
parent
8175a5ea
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
4 deletions
+55
-4
OpenfireX509TrustManager.java
...esoftware/openfire/keystore/OpenfireX509TrustManager.java
+55
-4
No files found.
src/java/org/jivesoftware/openfire/keystore/OpenfireX509TrustManager.java
View file @
99930932
...
@@ -2,6 +2,8 @@ package org.jivesoftware.openfire.keystore;
...
@@ -2,6 +2,8 @@ package org.jivesoftware.openfire.keystore;
import
org.bouncycastle.jce.provider.BouncyCastleProvider
;
import
org.bouncycastle.jce.provider.BouncyCastleProvider
;
import
org.jivesoftware.util.Log
;
import
org.jivesoftware.util.Log
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.net.ssl.*
;
import
javax.net.ssl.*
;
import
java.security.*
;
import
java.security.*
;
...
@@ -18,6 +20,8 @@ import java.util.*;
...
@@ -18,6 +20,8 @@ import java.util.*;
// TODO re-enable CRL checking.
// TODO re-enable CRL checking.
public
class
OpenfireX509TrustManager
implements
X509TrustManager
public
class
OpenfireX509TrustManager
implements
X509TrustManager
{
{
private
static
final
Logger
Log
=
LoggerFactory
.
getLogger
(
OpenfireX509TrustManager
.
class
);
private
static
final
Provider
PROVIDER
=
new
BouncyCastleProvider
();
private
static
final
Provider
PROVIDER
=
new
BouncyCastleProvider
();
static
static
...
@@ -66,6 +70,8 @@ public class OpenfireX509TrustManager implements X509TrustManager
...
@@ -66,6 +70,8 @@ public class OpenfireX509TrustManager implements X509TrustManager
}
}
trustedIssuers
=
Collections
.
unmodifiableSet
(
trusted
);
trustedIssuers
=
Collections
.
unmodifiableSet
(
trusted
);
Log
.
debug
(
"Constructed trust manager. Number of trusted issuers: {}, accepts self-signed: {}, checks validity: {}"
,
trustedIssuers
.
size
(),
acceptSelfSigned
,
checkValidity
);
}
}
@Override
@Override
...
@@ -222,10 +228,55 @@ public class OpenfireX509TrustManager implements X509TrustManager
...
@@ -222,10 +228,55 @@ public class OpenfireX509TrustManager implements X509TrustManager
// entire chain should now be in the store.
// entire chain should now be in the store.
parameters
.
addCertStore
(
certificates
);
parameters
.
addCertStore
(
certificates
);
// When true, validation will fail if no CRLs are provided!
parameters
.
setRevocationEnabled
(
false
);
Log
.
debug
(
"Validating chain with {} certificates, using {} trust anchors."
,
chain
.
length
,
trustAnchors
.
size
()
);
// Try to use BouncyCastle - if that doesn't work, pick one.
CertPathBuilder
pathBuilder
;
try
{
pathBuilder
=
CertPathBuilder
.
getInstance
(
"PKIX"
,
"BC"
);
}
catch
(
NoSuchProviderException
e
)
{
Log
.
warn
(
"Unable to use the BC provider! Trying to use a fallback provider."
,
e
);
pathBuilder
=
CertPathBuilder
.
getInstance
(
"PKIX"
);
}
try
{
// Finally, construct (and implicitly validate) the certificate path.
// Finally, construct (and implicitly validate) the certificate path.
final
CertPathBuilder
pathBuilder
=
CertPathBuilder
.
getInstance
(
"PKIX"
);
final
CertPathBuilderResult
result
=
pathBuilder
.
build
(
parameters
);
final
CertPathBuilderResult
result
=
pathBuilder
.
build
(
parameters
);
return
result
.
getCertPath
();
return
result
.
getCertPath
();
}
}
catch
(
CertPathBuilderException
ex
)
{
// This exception generally isn't very helpful. This block attempts to print more debug information.
try
{
Log
.
debug
(
"** Chain to be validated:"
);
Log
.
debug
(
" length: "
+
chain
.
length
);
for
(
int
i
=
0
;
i
<
chain
.
length
;
i
++)
{
Log
.
debug
(
" Certificate[{}] (valid from {} to {}):"
,
i
,
chain
[
i
].
getNotBefore
(),
chain
[
i
].
getNotAfter
()
);
Log
.
debug
(
" subjectDN: "
+
chain
[
i
].
getSubjectDN
()
);
Log
.
debug
(
" issuerDN: "
+
chain
[
i
].
getIssuerDN
()
);
for
(
X509Certificate
acceptedIssuer
:
acceptedIssuers
)
{
if
(
acceptedIssuer
.
getIssuerDN
().
equals
(
chain
[
i
].
getIssuerDN
()
)
)
{
Log
.
debug
(
"Found accepted issuer with same DN: "
+
acceptedIssuer
.
getIssuerDN
()
);
}
}
}
}
finally
{
// rethrow the original exception.
throw
ex
;
}
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment