diff options
Diffstat (limited to 'java/src/IceSSL/TransceiverI.java')
-rw-r--r-- | java/src/IceSSL/TransceiverI.java | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/java/src/IceSSL/TransceiverI.java b/java/src/IceSSL/TransceiverI.java index 60a434e7719..54687c5f052 100644 --- a/java/src/IceSSL/TransceiverI.java +++ b/java/src/IceSSL/TransceiverI.java @@ -274,6 +274,49 @@ final class TransceiverI implements IceInternal.Transceiver return _desc; } + public Ice.ConnectionInfo + getInfo() + { + assert(_fd != null); + + IceSSL.SSLConnectionInfo info = new IceSSL.SSLConnectionInfo(); + java.net.Socket socket = _fd.socket(); + info.localAddress = socket.getLocalAddress().getHostAddress(); + info.localPort = socket.getLocalPort(); + if(socket.getInetAddress() != null) + { + info.remoteAddress = socket.getInetAddress().getHostAddress(); + info.remotePort = socket.getPort(); + } + else + { + info.remoteAddress = ""; + info.remotePort = -1; + } + SSLSession session = _engine.getSession(); + info.cipher = session.getCipherSuite(); + try + { + java.util.ArrayList<String> certs = new java.util.ArrayList<String>(); + for(java.security.cert.Certificate c : session.getPeerCertificates()) + { + StringBuffer s = new StringBuffer("-----BEGIN CERTIFICATE-----\n"); + s.append(IceUtilInternal.Base64.encode(c.getEncoded())); + s.append("\n-----END CERTIFICATE-----"); + certs.add(s.toString()); + } + info.certs = certs.toArray(new String[0]); + } + catch(java.security.cert.CertificateEncodingException ex) + { + } + catch(javax.net.ssl.SSLPeerUnverifiedException ex) + { + // No peer certificates. + } + return info; + } + public void checkSendSize(IceInternal.Buffer buf, int messageSizeMax) { |