Skip to content

Commit 34c8db1

Browse files
committed
refactor
Signed-off-by: Abhishek Kumar <[email protected]>
1 parent eba9ea5 commit 34c8db1

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

utils/src/main/java/com/cloud/utils/nio/Link.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ public static KeyStore loadKeyStore(final InputStream stream, final char[] passp
362362
}
363363

364364
public static SSLEngine initServerSSLEngine(final CAService caService, final String clientAddress) throws GeneralSecurityException, IOException {
365-
final SSLContext sslContext = SSLUtils.getSSLContextWithLatestVersion();
365+
final SSLContext sslContext = SSLUtils.getSSLContextWithLatestProtocolVersion();
366366
if (caService != null) {
367367
return caService.createSSLEngine(sslContext, clientAddress);
368368
}
@@ -391,7 +391,7 @@ public static SSLContext initManagementSSLContext(final CAService caService) thr
391391
final KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
392392
kmf.init(ks, passphrase);
393393

394-
final SSLContext sslContext = SSLUtils.getSSLContextWithLatestVersion();
394+
final SSLContext sslContext = SSLUtils.getSSLContextWithLatestProtocolVersion();
395395
sslContext.init(kmf.getKeyManagers(), tms, new SecureRandom());
396396
return sslContext;
397397
}
@@ -435,7 +435,7 @@ public static SSLContext initClientSSLContext() throws GeneralSecurityException,
435435
final KeyManagerFactory kmf = KeyManagerFactory.getInstance("SunX509");
436436
kmf.init(ks, passphrase);
437437

438-
final SSLContext sslContext = SSLUtils.getSSLContextWithLatestVersion();
438+
final SSLContext sslContext = SSLUtils.getSSLContextWithLatestProtocolVersion();
439439
sslContext.init(kmf.getKeyManagers(), tms, new SecureRandom());
440440
return sslContext;
441441
}

utils/src/main/java/com/cloud/utils/nio/NioClient.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ protected void init() throws IOException {
7474
if (!Link.doHandshake(clientConnection, sslEngine, getSslHandshakeTimeout())) {
7575
throw new IOException(String.format("SSL Handshake failed while connecting to host: %s", hostLog));
7676
}
77-
logger.info("SSL: Handshake done");
77+
logger.info("SSL: Handshake done with {} protocol: {}, cipher suite: {}",
78+
serverAddress, sslEngine.getSession().getProtocol(), sslEngine.getSession().getCipherSuite());
7879

7980
final Link link = new Link(serverAddress, this);
8081
link.setSSLEngine(sslEngine);

utils/src/main/java/com/cloud/utils/nio/NioConnection.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,9 @@ protected void accept(final SelectionKey key) throws IOException {
274274
if (!Link.doHandshake(socketChannel, sslEngine, getSslHandshakeTimeout())) {
275275
throw new IOException("SSL handshake timed out with " + socketAddress);
276276
}
277-
logger.trace("SSL: Handshake done");
277+
logger.trace("SSL: Handshake done with {} protocol: {}, cipher suite: {}",
278+
socketAddress, sslEngine.getSession().getProtocol(),
279+
sslEngine.getSession().getCipherSuite());
278280
final Link link = new Link(socketAddress, nioConnection);
279281
link.setSSLEngine(sslEngine);
280282
link.setKey(socketChannel.register(key.selector(), SelectionKey.OP_READ, link));

utils/src/main/java/org/apache/cloudstack/utils/security/SSLUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static SSLContext getSSLContext() throws NoSuchAlgorithmException {
7070
return SSLContext.getInstance("TLSv1.2");
7171
}
7272

73-
public static SSLContext getSSLContextWithLatestVersion() throws NoSuchAlgorithmException {
73+
public static SSLContext getSSLContextWithLatestProtocolVersion() throws NoSuchAlgorithmException {
7474
return SSLContext.getInstance("TLSv1.3");
7575
}
7676

0 commit comments

Comments
 (0)