ServerHandshaker extends Handshaker { final CertificateType getNegotiatedServerCertificateType() { return selectedCipherSuiteParameters == null ? null : selectedCipherSuiteParameters.getSelectedServerCertificateType(); } ServerHandshaker(int initialMessageSequenceNo, DTLSSession session, RecordLayer recordLayer,
			ScheduledExecutorService timer, Connection connection, DtlsConnectorConfig config); PskPublicInformation getPreSharedKeyIdentity(); @Override void startHandshake(); @Override void destroy();  }
@Test public void testNegotiateCipherSuiteConsidersSupportedCertType() throws Exception { NewAdvancedCertificateVerifier verifier = StaticNewAdvancedCertificateVerifier.builder().setTrustAllRPKs().build(); config = DtlsConnectorConfig.builder() .setAddress(endpoint) .setIdentity(privateKey, DtlsTestTools.getPublicKey()) .setSupportedCipherSuites( CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8, CipherSuite.TLS_PSK_WITH_AES_128_CCM_8) .setAdvancedPskStore(new AdvancedSinglePskStore("client", "secret".getBytes())) .setAdvancedCertificateVerifier(verifier) .build(); handshaker = newHandshaker(config, session); supportedClientCiphers = new byte[]{(byte) 0xC0, (byte) 0xAE, (byte) 0xC0, (byte) 0xA8}; List<byte[]> extensions = new LinkedList<>(); SupportedGroup supportedGroup = getArbitrarySupportedGroup(); extensions.add(DtlsTestTools.newSupportedEllipticCurvesExtension(supportedGroup.getId())); processClientHello(0, extensions); assertThat(session.getCipherSuite(), is(CipherSuite.TLS_PSK_WITH_AES_128_CCM_8)); assertThat(handshaker.getNegotiatedServerCertificateType(), is(nullValue())); }
@Test public void testReceiveClientHelloAbortsOnUnknownServerCertificateType() throws Exception { List<byte[]> extensions = new LinkedList<>(); extensions.add(DtlsTestTools.newServerCertificateTypesExtension(0x05)); try { processClientHello(0, extensions); fail("Should have thrown " + HandshakeException.class.getSimpleName()); } catch(HandshakeException e) { assertThat(session.getCipherSuite(), is(CipherSuite.TLS_NULL_WITH_NULL_NULL)); assertThat(handshaker.getNegotiatedServerCertificateType(), is(nullValue())); } }