tls-psk: use automatically assigned port

This commit is contained in:
Vincent Breitmoser
2017-06-02 12:23:40 +02:00
parent 8a345d0c72
commit 3a728b94a6

View File

@@ -164,15 +164,14 @@ public class KeyTransferInteractor {
Socket socket; Socket socket;
if (isServer) { if (isServer) {
try { try {
int port = 1336; serverSocket = (SSLServerSocket) sslContext.getServerSocketFactory().createServerSocket(0);
serverSocket = (SSLServerSocket) sslContext.getServerSocketFactory().createServerSocket(port);
String[] supportedCipherSuites = serverSocket.getSupportedCipherSuites(); String[] supportedCipherSuites = serverSocket.getSupportedCipherSuites();
String[] enabledCipherSuites = intersectArrays(supportedCipherSuites, ALLOWED_CIPHERSUITES); String[] enabledCipherSuites = intersectArrays(supportedCipherSuites, ALLOWED_CIPHERSUITES);
serverSocket.setEnabledCipherSuites(enabledCipherSuites); serverSocket.setEnabledCipherSuites(enabledCipherSuites);
String presharedKeyEncoded = Hex.toHexString(presharedKey); String presharedKeyEncoded = Hex.toHexString(presharedKey);
String qrCodeData = String qrCodeData =
"pgp+transfer://" + presharedKeyEncoded + "@" + getIPAddress(true) + ":" + port; "pgp+transfer://" + presharedKeyEncoded + "@" + getIPAddress(true) + ":" + serverSocket.getLocalPort();
qrCodeData = qrCodeData.toUpperCase(Locale.getDefault()); qrCodeData = qrCodeData.toUpperCase(Locale.getDefault());
invokeListener(CONNECTION_LISTENING, qrCodeData); invokeListener(CONNECTION_LISTENING, qrCodeData);