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
5442e0f8
Commit
5442e0f8
authored
Sep 20, 2017
by
richmidwinter
Committed by
daryl herzmann
Sep 20, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OF-159: Add an s2s testing feature (#873)
Added some extra field details on s2s certificates.
parent
7883e51c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
4 deletions
+22
-4
S2STestService.java
src/java/org/jivesoftware/util/S2STestService.java
+22
-4
No files found.
src/java/org/jivesoftware/util/S2STestService.java
View file @
5442e0f8
package
org
.
jivesoftware
.
util
;
import
java.security.cert.Certificate
;
import
java.security.cert.CertificateParsingException
;
import
java.security.cert.X509Certificate
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.Semaphore
;
import
java.util.concurrent.TimeUnit
;
...
...
@@ -23,6 +25,7 @@ import org.jivesoftware.openfire.interceptor.PacketInterceptor;
import
org.jivesoftware.openfire.interceptor.PacketRejectedException
;
import
org.jivesoftware.openfire.session.OutgoingServerSession
;
import
org.jivesoftware.openfire.session.Session
;
import
org.jivesoftware.util.cert.SANCertificateIdentityMapping
;
import
org.slf4j.LoggerFactory
;
import
org.xmpp.packet.IQ
;
import
org.xmpp.packet.IQ.Type
;
...
...
@@ -167,12 +170,27 @@ public class S2STestService {
Log
.
info
(
"Successfully negotiated TLS connection."
);
Certificate
[]
certificates
=
session
.
getPeerCertificates
();
for
(
Certificate
certificate
:
certificates
)
{
certs
.
append
(((
X509Certificate
)
certificate
).
getSubjectDN
());
certs
.
append
(
'\n'
);
certs
.
append
(
"-----BEGIN CERTIFICATE-----\n"
);
X509Certificate
x509cert
=
(
X509Certificate
)
certificate
;
certs
.
append
(
"--\nSubject: "
);
certs
.
append
(
x509cert
.
getSubjectDN
());
List
<
String
>
subjectAltNames
=
new
SANCertificateIdentityMapping
().
mapIdentity
(
x509cert
);
if
(!
subjectAltNames
.
isEmpty
())
{
certs
.
append
(
"\nSubject Alternative Names: "
);
for
(
String
subjectAltName
:
subjectAltNames
)
{
certs
.
append
(
"\n "
);
certs
.
append
(
subjectAltName
);
}
}
certs
.
append
(
"\nNot Before: "
);
certs
.
append
(
x509cert
.
getNotBefore
());
certs
.
append
(
"\nNot After: "
);
certs
.
append
(
x509cert
.
getNotAfter
());
certs
.
append
(
"\n\n-----BEGIN CERTIFICATE-----\n"
);
certs
.
append
(
DatatypeConverter
.
printBase64Binary
(
certificate
.
getPublicKey
().
getEncoded
()).
replaceAll
(
"(.{64})"
,
"$1\n"
));
certs
.
append
(
"\n-----END CERTIFICATE-----\n"
);
certs
.
append
(
"\n-----END CERTIFICATE-----\n
\n
"
);
}
}
return
certs
.
toString
();
...
...
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