客户端 服务端
一、客户端有公钥和密钥,类似ssh登录
首先客户端要给公钥给服务端。
1、客户端向服务端发送数据
客户端使用自己的私钥加密数据,服务端接收后使用客户端的私钥来解密。
2、服务端向客户端发送数据
服务端使用客户端的私钥来加密数据,客户端使用自己的私钥来解密。
二、服务端有公钥和密钥,类似https访问
首先服务端会给客户端公钥。
1、服务端向客户端发送数据
服务端使用自己的私钥来加密数据,客户端使用服务度的公钥来解密。
2、客户端向服务端发送数据
客户端使用服务端的公钥加密数据,服务端接收后使用自己的私钥来解密。
共同点
公钥都是给对方的,对方会利用公钥解密接收数据和加密发送数据。
私钥都是留给自己的,自己可以利用私钥加密发送数据和解密接收数据。
图文参考
http://blog.csdn.net/bberdong/article/details/41079739