⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e500. creating an ssl server socket.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
An SSL server socket requires certificates that it will send to clients for authentication. The certificates must be contained in a keystore whose location must be explicitly specified (there is no default). Following the example we describe how to create and specify a keystore for the SSL server socket to use. 
    try {
        int port = 443;
        ServerSocketFactory ssocketFactory = SSLServerSocketFactory.getDefault();
        ServerSocket ssocket = ssocketFactory.createServerSocket(port);
    
        // Listen for connections
        Socket socket = ssocket.accept();
    
        // Create streams to securely send and receive data to the client
        InputStream in = socket.getInputStream();
        OutputStream out = socket.getOutputStream();
    
        // Read from in and write to out...
    
        // Close the socket
        in.close();
        out.close();
    } catch(IOException e) {
    }

Specify the keystore of certificates using the javax.net.ssl.keyStore system property: 
    > java -Djavax.net.ssl.keyStore=mySrvKeystore -Djavax.net.ssl.keyStorePassword=123456 MyServer


For testing purposes, you can create a keystore with a self-signed certificate, using the keytool command: 
    > keytool -keystore mySrvKeystore -keypasswd 123456 -genkey -keyalg RSA -alias mycert

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -