/** * Writes the CertificateLength of the SSL2ServerHello into the final byte[] */ private void writeCertificateLength(SSL2ServerHelloMessage message) { appendInt(message.getCertificateLength().getValue(), SSL2ByteLength.CERTIFICATE_LENGTH); LOGGER.debug("CertificateLength: " + message.getCertificateLength().getValue()); }
/** * Reads the next bytes as the CertificateLength and writes them in the * message * * @param message * Message to write in */ private void parseCertificateLength(SSL2ServerHelloMessage message) { message.setCertificateLength(parseIntField(SSL2ByteLength.CERTIFICATE_LENGTH)); LOGGER.debug("CertificateLength: " + message.getCertificateLength().getValue()); }
/** * Reads the next bytes as the Certificate and writes them in the message * * @param message * Message to write in */ private void parseCertificate(SSL2ServerHelloMessage message) { message.setCertificate(parseByteArrayField(message.getCertificateLength().getValue())); LOGGER.debug("Certificate: " + ArrayConverter.bytesToHexString(message.getCertificate().getValue())); }
@Override public void adjustTLSContext(SSL2ServerHelloMessage message) { byte[] serverRandom = message.getSessionId().getValue(); if (serverRandom != null) { tlsContext.setServerRandom(serverRandom); } Certificate cert = parseCertificate(message.getCertificateLength().getValue(), message.getCertificate() .getValue()); LOGGER.debug("Setting ServerCertificate in Context"); tlsContext.setServerCertificate(cert); if (cert == null || !CertificateUtils.hasRSAParameters(cert)) { LOGGER.error("Cannot parse Certificate from SSL2ServerHello"); } else { LOGGER.debug("Adjusting RSA PublicKey"); try { tlsContext.setServerRSAPublicKey(CertificateUtils.extractRSAPublicKey(cert)); tlsContext.setServerRsaModulus(CertificateUtils.extractRSAModulus(cert)); } catch (IOException e) { throw new AdjustmentException("Could not adjust PublicKey Information from Certificate", e); } } } }