s2nTLS/SSL 協(xié)議實(shí)現(xiàn)
s2n 是來(lái)自亞馬遜的一個(gè) TLS/SSL 協(xié)議的實(shí)現(xiàn),實(shí)現(xiàn)的目標(biāo)是簡(jiǎn)單、快速安全。
示例代碼:
/* Create a server mode connection handle */
struct s2n_connection *conn = s2n_connection_new(S2N_SERVER);
if (conn == NULL) {
... error ...
}
/* Associate a connection with a file descriptor */
if (s2n_connection_set_fd(conn, fd) < 0) {
... error ...
}
/* Negotiate the TLS handshake */
int more;
if (s2n_negotiate(conn, &more) < 0) {
... error ...
}
/* Write data to the connection */
int bytes_written;
bytes_written = s2n_send(conn, "Hello World", sizeof("Hello World"), &more);評(píng)論
圖片
表情
