Simple SSL Server

Wir sammeln alle Infos der Bonusepisode von Pokémon Karmesin und Purpur für euch!

Zu der Infoseite von „Die Mo-Mo-Manie“
  • hi


    ich bin gerade dabei zu testzwecken einen SSL-Server zu implementieren. Es kommt dabei nicht auf die Sicherheit, sondern auf die einfache und schnelle Umsetzung an. Insofern versuche ich die Certificate-Engine soweit wie möglich zu umgehen. Leider bekomme ich immer eine "no cipher suites in common"-Exception... (und der Browser zeigt eine "ssl_error_no_cypher_overlap" Fehlermeldung)


    Der Server wird über eine von mir geschriebene FactoryClass erstellt:

    Java
    import java.io.IOException;import java.net.ServerSocket;import java.security.KeyManagementException;import java.security.KeyPair;import java.security.KeyPairGenerator;import java.security.KeyStore;import java.security.KeyStoreException;import java.security.NoSuchAlgorithmException;import java.security.SecureRandom;import java.security.UnrecoverableKeyException;import java.security.cert.CertificateException;import java.security.cert.X509Certificate;import javax.net.ssl.KeyManagerFactory;import javax.net.ssl.SSLContext;import javax.net.ssl.TrustManager;import javax.net.ssl.X509TrustManager;public final class TSLFactory {	private TSLFactory(){}	private static KeyStore keyStore = null;	private static KeyManagerFactory keyManagaFactory = null;	private static SSLContext sslContext = null;	public static KeyStore getEmptyKeyStore() throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException{		KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());		keyStore.load(null, new char[0]);		return keyStore;	}	public static KeyStore simpleKeyStore(){		if(keyStore == null)			try{				keyStore = getEmptyKeyStore();			}catch(Exception e){			}		return keyStore;	}	public static KeyManagerFactory getKeyManagerFactory(KeyStore keyStore) throws NoSuchAlgorithmException, UnrecoverableKeyException, KeyStoreException{		KeyManagerFactory keyManagaFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());		keyManagaFactory.init(keyStore, new char[0]);		return keyManagaFactory;	}	public static KeyManagerFactory simpleKeyManagerFactory(){		if(keyManagaFactory == null)			try{				keyManagaFactory = getKeyManagerFactory(simpleKeyStore());			}catch(Exception e){			}		return keyManagaFactory;	}	public static SSLContext getSSLContext(KeyManagerFactory keyManagerKactory) throws NoSuchAlgorithmException, KeyManagementException{		SSLContext sslContext = SSLContext.getInstance("SSL");		sslContext.init(keyManagerKactory.getKeyManagers(), new TrustManager[]{new VoidTrustManager()}, new SecureRandom());		return sslContext;	}	public static SSLContext simpleSSLContext(){		if(sslContext == null)			try{				sslContext = getSSLContext(simpleKeyManagerFactory());			}catch(Exception e){			}		return sslContext;	}	public static ServerSocket getServerSocket(SSLContext sslContext, int port) throws IOException{		return sslContext.getServerSocketFactory().createServerSocket(port);	}	public static ServerSocket simpleServerSocket(int port) throws IOException{		return simpleSSLContext().getServerSocketFactory().createServerSocket(port);	}	private static class VoidTrustManager implements X509TrustManager{		VoidTrustManager(){}		@Override		public void checkClientTrusted(X509Certificate[] paramArrayOfX509Certificate, String paramString) throws CertificateException {		}		@Override		public void checkServerTrusted(X509Certificate[] paramArrayOfX509Certificate, String paramString) throws CertificateException {		}		@Override		public X509Certificate[] getAcceptedIssuers() {			return null;		}	}}


    bevor ich ihn in einer anderen Klasse konfiguriere: