@@ -0,0 +1,2851 @@
+package org.bouncycastle.crypto.tls.test;%0D%0A%0D%0Aimport java.io.IOException;%0D%0Aimport java.net.DatagramSocket;%0D%0Aimport java.net.InetAddress;%0D%0Aimport java.security.SecureRandom;%0D%0A%0D%0Aimport org.bouncycastle.asn1.x509.Certificate;%0D%0Aimport org.bouncycastle.crypto.tls.AlertDescription;%0D%0Aimport org.bouncycastle.crypto.tls.CertificateRequest;%0D%0Aimport org.bouncycastle.crypto.tls.CipherSuite;%0D%0Aimport org.bouncycastle.crypto.tls.DTLSProtocolHandler;%0D%0Aimport org.bouncycastle.crypto.tls.DefaultTlsClient;%0D%0Aimport org.bouncycastle.crypto.tls.ProtocolVersion;%0D%0Aimport org.bouncycastle.crypto.tls.TlsAuthentication;%0D%0Aimport org.bouncycastle.crypto.tls.TlsCredentials;%0D%0Aimport org.bouncycastle.crypto.tls.TlsFatalAlert;%0D%0Aimport org.bouncycastle.crypto.tls.UDPTransport;%0D%0A%0D%0Apublic class DTLSClientTest %7B%0D%0A%0D%0A    public static void main(String%5B%5D args) throws Exception %7B%0D%0A%0D%0A        DatagramSocket socket = new DatagramSocket();%0D%0A        socket.connect(InetAddress.getLocalHost(), 5556);%0D%0A%0D%0A        UDPTransport transport = new UDPTransport(socket, 2048, 1024);%0D%0A%0D%0A        SecureRandom secureRandom = new SecureRandom();%0D%0A        DTLSProtocolHandler dtls = new DTLSProtocolHandler(secureRandom);%0D%0A%0D%0A        DTLSClient client = new DTLSClient();%0D%0A        dtls.connect(client, transport);%0D%0A    %7D%0D%0A%0D%0A    static class DTLSClient extends DefaultTlsClient %7B%0D%0A%0D%0A        public int%5B%5D getCipherSuites() %7B%0D%0A            return new int%5B%5D %7B CipherSuite.TLS_RSA_WITH_AES_256_CBC_SHA,%0D%0A                CipherSuite.TLS_RSA_WITH_AES_128_CBC_SHA,%0D%0A                CipherSuite.TLS_RSA_WITH_3DES_EDE_CBC_SHA, %7D;%0D%0A        %7D%0D%0A%0D%0A        public ProtocolVersion getClientVersion() %7B%0D%0A            return ProtocolVersion.DTLSv10;%0D%0A        %7D%0D%0A%0D%0A        public TlsAuthentication getAuthentication() throws IOException %7B%0D%0A            return new TlsAuthentication() %7B%0D%0A                public void notifyServerCertificate(%0D%0A                    org.bouncycastle.crypto.tls.Certificate serverCertificate) throws IOException %7B%0D%0A                    Certificate%5B%5D chain = serverCertificate.getCerts();%0D%0A                    System.out.println(%22Received server certificate chain with %22 + chain.length%0D%0A                        + %22 entries%22);%0D%0A                    for (Certificate entry : chain) %7B%0D%0A                        System.out.println(%22    %22 + entry.getSubject());%0D%0A                    %7D%0D%0A                %7D%0D%0A%0D%0A                public TlsCredentials getClientCredentials(CertificateRequest certificateRequest)%0D%0A                    throws IOException %7B%0D%0A                    return null;%0D%0A                %7D%0D%0A            %7D;%0D%0A        %7D%0D%0A%0D%0A        public void notifyServerVersion(ProtocolVersion serverVersion) throws IOException %7B%0D%0A            if (!ProtocolVersion.DTLSv10.equals(serverVersion)) %7B%0D%0A                throw new TlsFatalAlert(AlertDescription.protocol_version);%0D%0A            %7D%0D%0A        %7D%0D%0A    %7D%0D%0A%7D%0D%0A

Add a test program for DTLS (for use with external GnuTLS echo server)