New script used to automatically generate SSL certificate files
Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>main
parent
ce2ac61e1f
commit
5757cbeb78
|
@ -50,3 +50,8 @@ modules.order
|
|||
Module.symvers
|
||||
Mkfile.old
|
||||
dkms.conf
|
||||
|
||||
server-cert.pem
|
||||
server-key.pem
|
||||
|
||||
build/
|
||||
|
|
|
@ -49,7 +49,7 @@ int main(int argc, char **argv)
|
|||
goto err;
|
||||
}
|
||||
|
||||
if (uh_ssl_init(srv, "server.pem", "server.key") < 0)
|
||||
if (uh_ssl_init(srv, "server-cert.pem", "server-key.pem") < 0)
|
||||
goto err;
|
||||
|
||||
uh_register_route(srv, "/test", route_test);
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
openssl req -x509 -newkey rsa:2048 -nodes -keyout server-key.pem -out server-cert.pem -config openssl.cnf
|
|
@ -0,0 +1,5 @@
|
|||
[ req ]
|
||||
distinguished_name = req_distinguished_name
|
||||
prompt = no
|
||||
[ req_distinguished_name ]
|
||||
CN = DONT USE - test cert for libuhttp
|
|
@ -86,6 +86,7 @@ int uh_register_route(struct uh_server *srv, const char *path, uh_route_handler_
|
|||
struct uh_value *uh_get_url(struct uh_connection *con);
|
||||
struct uh_value *uh_get_header(struct uh_connection *con, const char *name);
|
||||
|
||||
/* Init ssl for the server */
|
||||
int uh_ssl_init(struct uh_server *srv, const char *cert, const char *key);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -18,8 +18,13 @@ void __uh_log(const char *filename, int line, int priority, const char *format,
|
|||
|
||||
syslog(priority, "%s", buf);
|
||||
|
||||
|
||||
|
||||
#ifdef UH_DEBUG
|
||||
fprintf(stderr, "%s\n", buf);
|
||||
#else
|
||||
if (priority == LOG_ERR)
|
||||
fprintf(stderr, "%s\n", buf);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue