static DTLSTransport createServerTransport(final RTCCertificate rtcCertificate, final DatagramTransport transport) throws IOException { final DefaultTlsServer defaultTlsServer = new DefaultTlsServer() { private final AsymmetricKeyParameter privateKeyAsymKeyParam = PrivateKeyFactory.createKey(rtcCertificate.getKeyPair() .getPrivate() .getEncoded()); private final Certificate cCert = new Certificate(new org.bouncycastle.asn1.x509.Certificate[]{rtcCertificate.getCertificate().toASN1Structure()}); @Override protected ProtocolVersion getMaximumVersion() { return ProtocolVersion.DTLSv10; } @Override protected ProtocolVersion getMinimumVersion() { return ProtocolVersion.DTLSv10; } @Override protected TlsSignerCredentials getRSASignerCredentials() throws IOException { return new DefaultTlsSignerCredentials(this.context, this.cCert, this.privateKeyAsymKeyParam); } }; return new DTLSServerProtocol(SECURE_RANDOM).accept(defaultTlsServer, transport); }
static TlsSignerCredentials loadSignerCredentials(TlsContext context, String[] certResources, String keyResource) throws IOException { Certificate certificate = loadCertificateChain(certResources); AsymmetricKeyParameter privateKey = loadPrivateKeyResource(keyResource); return new DefaultTlsSignerCredentials(context, certificate, privateKey); }