s2n 是来自亚马逊的一个 TLS/SSL 协议的实现,实现的目标是简单、快速安全。
示例代码:
/* 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);