Ich bin zu digicert.com gegangen und habe die Zertifikate heruntergeladen, sie dann in den Mac-Schlüsselbund importiert und sie dann exportiert, wie ich gleich sehen werde. Ich verwende Netbeans. Ich habe das Gefühl, dass ich mit SSL „im Dunkeln arbeite“ und mir wurde dieser Teil nie beigebracht. Bitte helfen Sie!!
Code, der mit http-Anfragen funktioniert:
Code: Select all
public class ServerRequests {
public static final String CRLF = "\r\n";
ServerSocket s;
protected ServerSocket getServerSocket(int port) throws Exception{
return new ServerSocket(port);
}
public void runServer(int port) throws Exception{
s = getServerSocket(port);
while(true) {
try {
System.out.println("server is running");
Socket us = s.accept();
Handler(us);
} catch (IOException e) {
System.err.println(e);
}
}
}
public void Handler(Socket s) throws Exception, MessagingException {
Code: Select all
keytool -genkey -alias [my alias] -keyalg RSA -keystore [mystore.jks]
Code: Select all
Keytool -delete -alias [myalias] -keystore [mystore.jks]
I Verwenden Sie dann diesen Befehl, um eine PKCS12-Datei zu generieren:
Code: Select all
keytool -v -importkeystore -srckeystore [pathtoPKCS12.p12] -
srcstoretype PKCS12 -destkeystore [mystore.jks] -deststoretype
JKS
Code: Select all
protected ServerSocket getServerSocket(int port) throws Exception{
SSLServerSocketFactory ssf = (SSLServerSocketFactory)SSLServerSocketFactory.getDefault();
return ssf.createServerSocket(port);
}
public void runServer(int port) throws Exception{
System.setProperty("javax.net.ssl.keyStore", "/Users/evanredmond/[mystore].jks");
System.setProperty("javax.net.ssl.keyStorePassword", "passphrase");
s = getServerSocket(port);
while(true) {
try {
System.out.println("server is running");
SSLSocket us = (SSLSocket) s.accept();
Handler(us);
} catch (IOException e) {
System.err.println(e);
}
}
}
public void Handler(SSLSocket s) throws Exception, MessagingException {
DAS WURDE GEFANGEN: javax.net.ssl.SSLHandshakeException: (certificate_unknown) Schwerwiegende Warnung erhalten: Certificate_unknown
Ich habe versucht, „einzugeben“ TLS“ anstelle von „TLSv1.1“, zusammen mit der Nichtverwendung der Kette oder des x509-Zertifikats und nur des regulären Zertifikats.