I am trying to connect from my verticle to device that implement TLS-PSK encryption algorithm TLS_PSK_WITH_AES_128_CBC_SHA and protocol "TLSv1.2". I have an example of code where we use BouncyCastle library for communicate.
TlsPSKIdentity pskIdentity = new BasicTlsPSKIdentity("identity", Hex.decode("/*psk key*/d901308ef9c6997fabf3a88d80954e17ecfef43f5ad9a1fc780fdd07e5494ae6"));
Security.addProvider(new BouncyCastleProvider());
Socket socket = new Socket(InetAddress.getByName("some host"), 12345);
SecureRandom secureRandom = new SecureRandom();
MockPSKTlsClient client = new MockPSKTlsClient(null, pskIdentity);
TlsClientProtocol protocol = new TlsClientProtocol(
socket.getInputStream(),
socket.getOutputStream(),
secureRandom
);
protocol.connect(client);
OutputStream output = protocol.getOutputStream();
output.write("someMessage".getBytes("UTF-8"));
InputStream input = protocol.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(input));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(">>> " + line);
}
output.close();
input.close();
socket.close();
protocol.close();
I know that Vert.x Ssl options can be configured in keystore/trustore format. My task is to implement this in Vert.x. Can anybody help me understand how can I get successful connection with PSK and vertx NetClient?