CertificateMessage extends HandshakeMessage { public PublicKey getPublicKey() { return publicKey; } CertificateMessage(List<X509Certificate> certificateChain, InetSocketAddress peerAddress);  CertificateMessage(List<X509Certificate> certificateChain, List<X500Principal> certificateAuthorities,
			InetSocketAddress peerAddress); private  CertificateMessage(CertPath peerCertChain, InetSocketAddress peerAddress);  CertificateMessage(PublicKey publicKey, InetSocketAddress peerAddress);  CertificateMessage(byte[] rawPublicKeyBytes, InetSocketAddress peerAddress); @Override HandshakeType getMessageType(); @Override int getMessageLength(); @Override String toString(); CertPath getCertificateChain(); boolean isEmpty(); @Override byte[] fragmentToByteArray(); static CertificateMessage fromReader(
			DatagramReader reader,
			CertificateType certificateType,
			InetSocketAddress peerAddress); PublicKey getPublicKey();  }
@Test public void testSerializationUsingRawPublicKey() throws IOException, GeneralSecurityException, HandshakeException { givenACertificateMessage(DtlsTestTools.getServerCertificateChain(), true); HandshakeParameter parameter = new HandshakeParameter(KeyExchangeAlgorithm.EC_DIFFIE_HELLMAN, CertificateType.RAW_PUBLIC_KEY); PublicKey pk = message.getPublicKey(); assertNotNull(pk); serializedMessage = message.toByteArray(); CertificateMessage msg = DtlsTestTools.fromByteArray(serializedMessage, parameter, peerAddress); assertThat(msg.getPublicKey(), is(pk)); }
@Test public void testSerializationUsingX509() throws IOException, GeneralSecurityException, HandshakeException { givenACertificateMessage(DtlsTestTools.getServerCertificateChain(), false); HandshakeParameter parameter = new HandshakeParameter(KeyExchangeAlgorithm.EC_DIFFIE_HELLMAN, CertificateType.X_509); PublicKey pk = message.getPublicKey(); assertNotNull(pk); serializedMessage = message.toByteArray(); CertificateMessage msg = DtlsTestTools.fromByteArray(serializedMessage, parameter, peerAddress); assertThat(msg.getPublicKey(), is(pk)); }