|
6 | 6 | #include <stdlib.h>
|
7 | 7 | #include <string.h>
|
8 | 8 |
|
| 9 | +#ifndef LIBUS_NO_SSL |
| 10 | +#define us_socket us_ssl_socket |
| 11 | +#define us_socket_context us_ssl_socket_context |
| 12 | +#define us_socket_write us_ssl_socket_write |
| 13 | +#define us_socket_close us_ssl_socket_close |
| 14 | +#define us_socket_shutdown us_ssl_socket_shutdown |
| 15 | +#define us_socket_context_on_end us_ssl_socket_context_on_end |
| 16 | +#define us_socket_context_on_open us_ssl_socket_context_on_open |
| 17 | +#define us_socket_context_on_close us_ssl_socket_context_on_close |
| 18 | +#define us_socket_context_on_writable us_ssl_socket_context_on_writable |
| 19 | +#define us_socket_context_on_data us_ssl_socket_context_on_data |
| 20 | +#define us_socket_context_on_timeout us_ssl_socket_context_on_timeout |
| 21 | +#define us_socket_ext us_ssl_socket_ext |
| 22 | +#define us_socket_context_ext us_ssl_socket_context_ext |
| 23 | +#define us_socket_get_context us_ssl_socket_get_context |
| 24 | +#define us_socket_context_listen us_ssl_socket_context_listen |
| 25 | +#define us_socket_timeout us_ssl_socket_timeout |
| 26 | +#endif |
| 27 | + |
9 | 28 | struct http_socket {
|
10 | 29 | /* How far we have streamed our response */
|
11 | 30 | int offset;
|
@@ -83,7 +102,16 @@ int main() {
|
83 | 102 | struct us_loop *loop = us_create_loop(1, on_wakeup, on_pre, on_post, 0);
|
84 | 103 |
|
85 | 104 | /* Create a socket context for HTTP */
|
| 105 | +#ifndef LIBUS_NO_SSL |
| 106 | + struct us_ssl_socket_context_options ssl_options = {}; |
| 107 | + ssl_options.key_file_name = "/home/alexhultman/uWebSockets/misc/ssl/key.pem"; |
| 108 | + ssl_options.cert_file_name = "/home/alexhultman/uWebSockets/misc/ssl/cert.pem"; |
| 109 | + ssl_options.passphrase = "1234"; |
| 110 | + |
| 111 | + struct us_ssl_socket_context *http_context = us_create_ssl_socket_context(loop, sizeof(struct http_context), ssl_options); |
| 112 | +#else |
86 | 113 | struct us_socket_context *http_context = us_create_socket_context(loop, sizeof(struct http_context));
|
| 114 | +#endif |
87 | 115 |
|
88 | 116 | /* Generate the shared response */
|
89 | 117 | const char body[] = "<html><body><h1>Why hello there!</h1></body></html>";
|
|
0 commit comments