mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-29 12:41:03 +00:00
Add Zephyr examples
This commit is contained in:
1 parent
6e3e77a1a0
commit
17e0fb1c15
21 files changed
+757
-19
No files matched your search
@@ -0,0 +1,24 @@
|
||||
#ifndef CERTS_H_
|
||||
#define CERTS_H_
|
||||
|
||||
static const char *s_ssl_cert =
|
||||
"-----BEGIN CERTIFICATE-----\r\n" \
|
||||
"MIIBhzCCASygAwIBAgIUbnMoVd8TtWH1T09dANkK2LU6IUswCgYIKoZIzj0EAwIw\r\n" \
|
||||
"RDELMAkGA1UEBhMCSUUxDzANBgNVBAcMBkR1YmxpbjEQMA4GA1UECgwHQ2VzYW50\r\n" \
|
||||
"YTESMBAGA1UEAwwJVGVzdCBSb290MB4XDTIwMDUwOTIxNTE0OVoXDTMwMDUwOTIx\r\n" \
|
||||
"NTE0OVowETEPMA0GA1UEAwwGc2VydmVyMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcD\r\n" \
|
||||
"QgAEkuBGnInDN6l06zVVQ1VcrOvH5FDu9MC6FwJc2e201P8hEpq0Q/SJS2nkbSuW\r\n" \
|
||||
"H/wBTTBaeXN2uhlBzMUWK790KKMvMC0wCQYDVR0TBAIwADALBgNVHQ8EBAMCA6gw\r\n" \
|
||||
"EwYDVR0lBAwwCgYIKwYBBQUHAwEwCgYIKoZIzj0EAwIDSQAwRgIhAPo6xx7LjCdZ\r\n" \
|
||||
"QY133XvLjAgVFrlucOZHONFVQuDXZsjwAiEAzHBNligA08c5U3SySYcnkhurGg50\r\n" \
|
||||
"BllCI0eYQ9ggp/o=\r\n" \
|
||||
"-----END CERTIFICATE-----\r\n";
|
||||
|
||||
static const char *s_ssl_key =
|
||||
"-----BEGIN PRIVATE KEY-----\r\n" \
|
||||
"MIGHAgEAMBMGByqGSM49AgEGCCqGSM49AwEHBG0wawIBAQQglNni0t9Dg9icgG8w\r\n" \
|
||||
"kbfxWSS+TuNgbtNybIQXcm3NHpmhRANCAASS4EacicM3qXTrNVVDVVys68fkUO70\r\n" \
|
||||
"wLoXAlzZ7bTU/yESmrRD9IlLaeRtK5Yf/AFNMFp5c3a6GUHMxRYrv3Qo\r\n" \
|
||||
"-----END PRIVATE KEY-----\r\n";
|
||||
|
||||
#endif
|
||||
@@ -2,20 +2,19 @@
|
||||
// All rights reserved
|
||||
|
||||
#include "mongoose.h"
|
||||
#include "certs.h"
|
||||
|
||||
static const char *s_debug_level = "3";
|
||||
static const char *s_web_dir = "/";
|
||||
static const char *s_http_addr = "http://0.0.0.0:8000";
|
||||
static const char *s_https_addr = "https://0.0.0.0:8443";
|
||||
static const char *s_cert = "cert.pem";
|
||||
static const char *s_key = "key.pem";
|
||||
static time_t s_boot_timestamp = 0;
|
||||
static struct mg_connection *s_sntp_conn = NULL;
|
||||
|
||||
// Event handler for the listening HTTP/HTTPS connection.
|
||||
static void wcb(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
|
||||
if (ev == MG_EV_ACCEPT && fn_data != NULL) {
|
||||
struct mg_tls_opts opts = {.cert = s_cert, .certkey = s_key};
|
||||
struct mg_tls_opts opts = {.cert = s_ssl_cert, .certkey = s_ssl_key};
|
||||
mg_tls_init(c, &opts);
|
||||
} else if (ev == MG_EV_HTTP_MSG) {
|
||||
struct mg_http_message *hm = ev_data;
|
||||
|
||||
Reference in new issue
Block a user