Skip to content

Commit ff2c2c4

Browse files
author
kasemir
committed
PVA: Log, instanceof
1 parent 67f4fa9 commit ff2c2c4

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

core/pva/src/main/java/org/epics/pva/common/SecureSockets.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public static Socket createClientSocket(final InetSocketAddress address, final b
213213
logger.log(Level.FINE, " - Self-signed");
214214

215215
byte[] value = x509.getExtensionValue("1.3.6.1.4.1.37427.1");
216-
logger.log(Level.FINE, " - Status PV: " + decodeDERString(value));
216+
logger.log(Level.FINE, " - Status PV: '" + decodeDERString(value) + "'");
217217
}
218218
}
219219
catch (Exception ex)
@@ -227,13 +227,13 @@ public static Socket createClientSocket(final InetSocketAddress address, final b
227227

228228
/** Decode DER String
229229
* @param der_value
230-
* @return
230+
* @return String, never null
231231
* @throws Exception on error
232232
*/
233233
public static String decodeDERString(final byte[] der_value) throws Exception
234234
{
235235
if (der_value == null)
236-
return null;
236+
return "";
237237
// https://en.wikipedia.org/wiki/X.690#DER_encoding:
238238
// Type 4, length 0..127, characters
239239
if (der_value.length < 2)
@@ -328,7 +328,7 @@ public static TLSHandshakeInfo fromSocket(final SSLSocket socket) throws Excepti
328328

329329
byte[] value = x509.getExtensionValue("1.3.6.1.4.1.37427.1");
330330
String pv_name = SecureSockets.decodeDERString(value);
331-
logger.log(Level.FINER, " - Status PV: " + pv_name);
331+
logger.log(Level.FINER, " - Status PV: '" + pv_name + "'");
332332

333333
if (is_principal_cert && pv_name != null && !pv_name.isBlank())
334334
status_pv_name = pv_name;

core/pva/src/main/java/org/epics/pva/server/ServerTCPListener.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
*
3535
* @author Kay Kasemir
3636
*/
37-
@SuppressWarnings("nls")
3837
class ServerTCPListener
3938
{
4039
private final ExecutorService thread_pool = Executors.newCachedThreadPool(runnable ->
@@ -222,16 +221,13 @@ private void listen()
222221
{ // Check TLS
223222
final Socket client = tls_server_socket.accept();
224223
TLSHandshakeInfo tls_info = null;
225-
if (client instanceof SSLSocket)
224+
if (client instanceof SSLSocket ssl_client)
226225
{
227226
logger.log(Level.FINE, () -> Thread.currentThread().getName() + " accepted TLS client " + client.getRemoteSocketAddress());
228227
try
229228
{
230-
tls_info = TLSHandshakeInfo.fromSocket((SSLSocket) client);
229+
tls_info = TLSHandshakeInfo.fromSocket(ssl_client);
231230
logger.log(Level.FINE, "Client TLS info: " + tls_info);
232-
// TODO Monitor status PV, close connection when PV shows expired/revoked cert
233-
// if (! tls_info.status_pv_name.isEmpty() /* && PVASettings.CHECK_CERT_STATUS */)
234-
// logger.log(Level.INFO, "Should check " + tls_info.status_pv_name);
235231
}
236232
catch (SSLHandshakeException ssl)
237233
{

0 commit comments

Comments
 (0)