/** * Writes the Certificate of the SSL2ServerHello into the final byte[] */ private void writeCertificate(SSL2ServerHelloMessage message) { appendBytes(message.getCertificate().getValue()); LOGGER.debug("Certificate: " + ArrayConverter.bytesToHexString(message.getCertificate().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); } } } }
if (getCertificate() != null && getCertificate().getValue() != null) { sb.append(ArrayConverter.bytesToHexString(getCertificate().getValue())); } else { sb.append("null");