Skip to content

Commit

Permalink
Merge pull request #269 from WesGilster/master
Browse files Browse the repository at this point in the history
Attempt to fix BLOCKING call
  • Loading branch information
WesGilster authored Oct 15, 2016
2 parents b665c71 + 72115a1 commit 0b03dfb
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,18 @@ public IncomingHttpTunnel(RendezvousClient server, URI rendezvousServerWebSocket
public void sendCertificateTrustExchange(PhotonicCrypto fromLocalCrypto, UUID toRemote) throws CertificateEncodingException, JsonProcessingException, IOException {
ObjectMapper mapper = new ObjectMapper(new JsonFactory());
Message message = fromLocalCrypto.buildCertificateTrustMessage(toRemote);
session.getRemote().sendBytes(ByteBuffer.wrap(mapper.writeValueAsBytes(message)));
synchronized (session.getRemote()) {
session.getRemote().sendBytes(ByteBuffer.wrap(mapper.writeValueAsBytes(message)));
}
//TODO: Someday we should wait for an accept friend response from the remote.
}

public void sendKeyExchange(PhotonicCrypto crypto) throws CertificateExpiredException, CertificateNotYetValidException, InvalidKeyException, InvalidNameException, NoSuchAlgorithmException, SignatureException, NoSuchPaddingException, IllegalBlockSizeException, BadPaddingException, JsonProcessingException, IOException {
ObjectMapper mapper = new ObjectMapper(new JsonFactory());
Message message = crypto.buildKeyExchange();
session.getRemote().sendBytes(ByteBuffer.wrap(mapper.writeValueAsBytes(message)));
synchronized (session.getRemote()) {
session.getRemote().sendBytes(ByteBuffer.wrap(mapper.writeValueAsBytes(message)));
}
//TODO: Someday we should wait for a key receipt message
}

Expand Down Expand Up @@ -277,7 +281,9 @@ public void onMessage(byte buf[], int offset, int length) {
buffer.put(responseString.getBytes());
buffer.put(response);
Message outMessage = connection.getCrypto().buildEncryptedMessage(buffer);
session.getRemote().sendBytes(ByteBuffer.wrap(mapper.writeValueAsBytes(outMessage)));
synchronized (session.getRemote()) {
session.getRemote().sendBytes(ByteBuffer.wrap(mapper.writeValueAsBytes(outMessage)));
}
} catch (IOException | InvalidNameException | InvalidAlgorithmParameterException | InvalidKeyException | IllegalBlockSizeException | BadPaddingException | NoSuchPaddingException | NoSuchAlgorithmException e) {
logger.error(e);
}
Expand Down

0 comments on commit 0b03dfb

Please sign in to comment.