/** * Stores the negotiated security parameters. * * @param message the {@link ServerHello} message. */ private void receivedServerHello(ServerHello message) { if (serverHello != null && (message.getMessageSeq() == serverHello.getMessageSeq())) { // received duplicate version (retransmission), discard it return; } serverHello = message; // store the negotiated values usedProtocol = message.getServerVersion(); serverRandom = message.getRandom(); session.setSessionIdentifier(message.getSessionId()); setCipherSuite(message.getCipherSuite()); setCompressionMethod(message.getCompressionMethod()); ClientCertificateTypeExtension clientCertType = serverHello.getClientCertificateTypeExtension(); // check what the server indicates for the certificate's type if (clientCertType != null && clientCertType.getCertificateTypes().get(0) == CertificateType.RAW_PUBLIC_KEY) { session.setReceiveRawPublicKey(true); } ServerCertificateTypeExtension serverCertType = serverHello.getServerCertificateTypeExtension(); // check what the client should send if (serverCertType != null && serverCertType.getCertificateTypes().get(0) == CertificateType.RAW_PUBLIC_KEY) { session.setSendRawPublicKey(true); } }
public static HelloExtension fromByteArray(byte[] byteArray, ExtensionType type) throws HandshakeException { switch (type) { // the currently supported extensions, throws an exception if other extension type received case ELLIPTIC_CURVES: return SupportedEllipticCurvesExtension.fromByteArray(byteArray); case EC_POINT_FORMATS: return SupportedPointFormatsExtension.fromByteArray(byteArray); case CLIENT_CERT_TYPE: return ClientCertificateTypeExtension.fromByteArray(byteArray); case SERVER_CERT_TYPE: return ServerCertificateTypeExtension.fromByteArray(byteArray); default: AlertMessage alert = new AlertMessage(AlertLevel.FATAL, AlertDescription.UNSUPPORTED_EXTENSION); throw new HandshakeException( "Unsupported extension type received: " + type.toString(), alert); } }