mirror of https://github.com/sipwise/jitsi.git
Logging of TLS protocols and cipher suites available during connection establishment and then the chosen ones.
Add ability to access TLS cipher suite, protocol name and server certificate using an new OperationSet. Only implemented for XMPP so far. Also makes this information available in the call information frame.fix-message-formatting
parent
183b69c82f
commit
8108adbc00
@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.impl.gui.main.call;
|
||||
|
||||
import java.awt.*;
|
||||
import java.security.cert.*;
|
||||
import javax.swing.*;
|
||||
import net.java.sip.communicator.plugin.desktoputil.*;
|
||||
import org.jitsi.service.resources.*;
|
||||
|
||||
/**
|
||||
* Frame for showing information about a certificate.
|
||||
*/
|
||||
public class ViewCertificateFrame extends SIPCommFrame {
|
||||
|
||||
/**
|
||||
* Serial version UID.
|
||||
*/
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
/**
|
||||
* The resource service.
|
||||
*/
|
||||
private final ResourceManagementService R = DesktopUtilActivator.getResources();
|
||||
|
||||
/**
|
||||
* The maximum width that we allow message dialogs to have.
|
||||
*/
|
||||
private static final int MAX_MSG_PANE_WIDTH = 600;
|
||||
|
||||
/**
|
||||
* The maximum height that we allow message dialogs to have.
|
||||
*/
|
||||
private static final int MAX_MSG_PANE_HEIGHT = 800;
|
||||
|
||||
/**
|
||||
* The certificate to show.
|
||||
*/
|
||||
Certificate cert;
|
||||
|
||||
/**
|
||||
* A text that describes why the verification failed.
|
||||
*/
|
||||
String message;
|
||||
|
||||
/**
|
||||
* The certificate panel.
|
||||
*/
|
||||
TransparentPanel certPanel;
|
||||
|
||||
/**
|
||||
* This dialog content pane.
|
||||
*/
|
||||
TransparentPanel contentPane;
|
||||
|
||||
/**
|
||||
* Creates the dialog.
|
||||
*
|
||||
* @param certs the certificates list
|
||||
* @param title The title of the dialog; when null the resource
|
||||
* <tt>service.gui.CERT_DIALOG_TITLE</tt> is loaded.
|
||||
* @param message A text that describes why the verification failed.
|
||||
*/
|
||||
public ViewCertificateFrame(Certificate[] certs,
|
||||
String title, String message)
|
||||
{
|
||||
super(false);
|
||||
|
||||
setTitle(title != null ? title :
|
||||
R.getI18NString("service.gui.CERT_DIALOG_TITLE"));
|
||||
|
||||
// for now shows only the first certificate from the chain
|
||||
this.cert = certs[0];
|
||||
this.message = message;
|
||||
|
||||
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
|
||||
init();
|
||||
|
||||
setLocationRelativeTo(getParent());
|
||||
}
|
||||
|
||||
/**
|
||||
* Inits the dialog initial display.
|
||||
*/
|
||||
private void init()
|
||||
{
|
||||
this.getContentPane().setLayout(new BorderLayout());
|
||||
|
||||
contentPane =
|
||||
new TransparentPanel(new BorderLayout(5, 5));
|
||||
|
||||
TransparentPanel northPanel =
|
||||
new TransparentPanel(new BorderLayout(5, 5));
|
||||
northPanel.setBorder(BorderFactory.createEmptyBorder(10, 5, 5, 5));
|
||||
|
||||
JLabel imgLabel = new JLabel(
|
||||
R.getImage("service.gui.icons.CERTIFICATE_WARNING"));
|
||||
imgLabel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||
northPanel.add(imgLabel, BorderLayout.WEST);
|
||||
|
||||
StyledHTMLEditorPane descriptionPane = new StyledHTMLEditorPane();
|
||||
descriptionPane.setOpaque(false);
|
||||
descriptionPane.setEditable(false);
|
||||
descriptionPane.setContentType("text/html");
|
||||
descriptionPane.setText(message);
|
||||
descriptionPane.setSize(
|
||||
new Dimension(MAX_MSG_PANE_WIDTH, MAX_MSG_PANE_HEIGHT));
|
||||
int height = descriptionPane.getPreferredSize().height;
|
||||
descriptionPane.setPreferredSize(
|
||||
new Dimension(MAX_MSG_PANE_WIDTH, height));
|
||||
|
||||
northPanel.add(descriptionPane, BorderLayout.CENTER);
|
||||
contentPane.add(northPanel, BorderLayout.NORTH);
|
||||
|
||||
certPanel = new TransparentPanel(new BorderLayout());
|
||||
contentPane.add(certPanel, BorderLayout.CENTER);
|
||||
|
||||
this.getContentPane().add(contentPane, BorderLayout.CENTER);
|
||||
|
||||
Component certInfoPane;
|
||||
if(cert instanceof X509Certificate)
|
||||
{
|
||||
certInfoPane = new X509CertificatePanel((X509Certificate)cert);
|
||||
}
|
||||
else
|
||||
{
|
||||
JTextArea textArea = new JTextArea();
|
||||
textArea.setOpaque(false);
|
||||
textArea.setEditable(false);
|
||||
textArea.setText(cert.toString());
|
||||
certInfoPane = textArea;
|
||||
}
|
||||
|
||||
final JScrollPane certScroll = new JScrollPane(certInfoPane);
|
||||
certScroll.setPreferredSize(new Dimension(300, 600));
|
||||
certPanel.add(certScroll, BorderLayout.CENTER);
|
||||
|
||||
SwingUtilities.invokeLater(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
certScroll.getVerticalScrollBar().setValue(0);
|
||||
}
|
||||
});
|
||||
setPreferredSize(null);
|
||||
|
||||
pack();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.impl.protocol.jabber;
|
||||
|
||||
import java.security.cert.*;
|
||||
import javax.net.ssl.*;
|
||||
|
||||
import net.java.sip.communicator.service.protocol.*;
|
||||
|
||||
/**
|
||||
* An implementation of the OperationSetTLS for the Jabber protocol.
|
||||
*
|
||||
* @author Markus Kilås
|
||||
*/
|
||||
public class OperationSetTLSJabberImpl
|
||||
implements OperationSetTLS
|
||||
{
|
||||
private final ProtocolProviderServiceJabberImpl jabberService;
|
||||
|
||||
public OperationSetTLSJabberImpl(
|
||||
ProtocolProviderServiceJabberImpl jabberService)
|
||||
{
|
||||
this.jabberService = jabberService;
|
||||
}
|
||||
|
||||
public String getCipherSuite() {
|
||||
final String result;
|
||||
final SSLSocket socket = jabberService.getSSLSocket();
|
||||
if (socket == null)
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = socket.getSession().getCipherSuite();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String getProtocol() {
|
||||
final String result;
|
||||
final SSLSocket socket = jabberService.getSSLSocket();
|
||||
if (socket == null)
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = socket.getSession().getProtocol();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public Certificate[] getServerCertificates() {
|
||||
Certificate[] result = null;
|
||||
final SSLSocket socket = jabberService.getSSLSocket();
|
||||
if (socket != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
result = socket.getSession().getPeerCertificates();
|
||||
}
|
||||
catch (SSLPeerUnverifiedException ignored) // NOPMD
|
||||
{
|
||||
// result will be null
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Jitsi, the OpenSource Java VoIP and Instant Messaging client.
|
||||
*
|
||||
* Distributable under LGPL license.
|
||||
* See terms of license at gnu.org.
|
||||
*/
|
||||
package net.java.sip.communicator.service.protocol;
|
||||
|
||||
import java.security.cert.*;
|
||||
|
||||
/**
|
||||
* An <tt>OperationSet</tt> that allows access to information about TLS used by
|
||||
* the protocol provider.
|
||||
*
|
||||
* @author Markus Kilås
|
||||
*/
|
||||
public interface OperationSetTLS
|
||||
extends OperationSet
|
||||
{
|
||||
/**
|
||||
* Returns the negotiated cipher suite
|
||||
*
|
||||
* @return The cipher suite name used for instance
|
||||
* "TLS_RSA_WITH_AES_256_CBC_SHA" or null if TLS is not used.
|
||||
*/
|
||||
String getCipherSuite();
|
||||
|
||||
/**
|
||||
* Returns the negotiated SSL/TLS protocol.
|
||||
*
|
||||
* @return The protocol name used for instance "TLSv1".
|
||||
*/
|
||||
String getProtocol();
|
||||
|
||||
/**
|
||||
* Returns the TLS server certificate chain with the end entity certificate
|
||||
* in the first position and the issuers following (if any returned by the
|
||||
* server).
|
||||
*
|
||||
* @return The TLS server certificate chain.
|
||||
*/
|
||||
Certificate[] getServerCertificates();
|
||||
}
|
||||
Loading…
Reference in new issue