forked from pBlueG/Socket
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathssl_sample.pwn
More file actions
35 lines (33 loc) · 925 Bytes
/
ssl_sample.pwn
File metadata and controls
35 lines (33 loc) · 925 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <socket>
// sample function of how to create a SSL server
stock TCP_SSL_server()
{
new Socket:sock = socket_create(TCP);
if(is_socket_valid(sock)) {
ssl_init();
ssl_create_context(sock, METHOD_SERVER);
ssl_load_cert_into_context(sock, "path/to/certifate.crt", "path/to/key.key");
socket_set_max_connections(sock, 10);
ssl_set_accept_timeout(sock, 3000);
socket_listen(sock, 1337);
return 1;
}
return 0;
}
// sample function for a SSL client
stock TCP_SSL_client()
{
new Socket:sock = socket_create(TCP);
if(is_socket_valid(sock)) {
ssl_init();
ssl_create_context(sock, METHOD_CLIENT);
if(socket_connect(sock, "somesite.com", 443)) {
if(ssl_connect(sock)) {
// our ssl context (object) has successfully connected to our socket handle
//socket_send(sock, "GET /\r\n\r\n", 13);
return 1;
}
}
}
return 0;
}