Jam*_*sev 4 java sockets security client-server
假设客户端和服务器应用程序在不同的计算机上运行
今天:
// Server will receive the request and cast it as needed
ProxyResponse message = (ProxyResponse) objStream.readObject();
// Update message with some content
...
// Sent it back to client
ObjectOutputStream oos = new ObjectOutputStream(toClient);
oos.writeObject(message);
Run Code Online (Sandbox Code Playgroud)
我想进一步加强这一点,以确保发出的数据以某种方式受到保护.您如何推荐我接近这个?
我正在寻找一个例子,说明在客户端和服务器之间传递的数据如何在两端加密和解密并通过SSL发送.
Dan*_*ett 12
JDK 提供了一个SSL套接字 实现,似乎是一个合适的起点.它很简单易用.
最初,您可能有这样的代码:
final SocketFactory factory = SocketFactory.getDefault();
final Socket socket = factory.createSocket(host, port);
Run Code Online (Sandbox Code Playgroud)
你只需更改工厂:
final SocketFactory factory = SSLSocketFactory.getDefault();
final Socket socket = factory.createSocket(host, port);
Run Code Online (Sandbox Code Playgroud)
同样如此ServerSocketFactory
.
归档时间: |
|
查看次数: |
9522 次 |
最近记录: |