mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-25 20:02:37 +03:00
* axhttpd can load a certificate and private key from the command line
* axssl now prints all output regardless of null bytes. It no longer writes a null byte. git-svn-id: svn://svn.code.sf.net/p/axtls/code/trunk@242 9a5d90b5-6617-0410-8a86-bb477d3ed2e3
This commit is contained in:
parent
b3fc32689d
commit
b9d43265b5
@ -153,9 +153,9 @@ typedef struct
|
|||||||
uint8_t buffer[64]; /* input buffer */
|
uint8_t buffer[64]; /* input buffer */
|
||||||
} MD5_CTX;
|
} MD5_CTX;
|
||||||
|
|
||||||
void MD5_Init(MD5_CTX *);
|
EXP_FUNC void STDCALL MD5_Init(MD5_CTX *);
|
||||||
void MD5_Update(MD5_CTX *, const uint8_t *msg, int len);
|
EXP_FUNC void STDCALL MD5_Update(MD5_CTX *, const uint8_t *msg, int len);
|
||||||
void MD5_Final(uint8_t *digest, MD5_CTX *);
|
EXP_FUNC void STDCALL MD5_Final(uint8_t *digest, MD5_CTX *);
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* HMAC declarations
|
* HMAC declarations
|
||||||
|
@ -128,7 +128,10 @@ int main(int argc, char *argv[])
|
|||||||
int httpPort = CONFIG_HTTP_PORT;
|
int httpPort = CONFIG_HTTP_PORT;
|
||||||
char *httpsAddress = NULL;
|
char *httpsAddress = NULL;
|
||||||
int httpsPort = CONFIG_HTTP_HTTPS_PORT;
|
int httpsPort = CONFIG_HTTP_HTTPS_PORT;
|
||||||
|
uint32_t options = CONFIG_HTTP_DEFAULT_SSL_OPTIONS;
|
||||||
char *portStr;
|
char *portStr;
|
||||||
|
char *private_key = NULL;
|
||||||
|
char *cert = NULL;
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
WORD wVersionRequested = MAKEWORD(2, 2);
|
WORD wVersionRequested = MAKEWORD(2, 2);
|
||||||
@ -190,9 +193,24 @@ int main(int argc, char *argv[])
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strcmp(argv[i], "-cert") == 0 && argv[i+1] != NULL)
|
||||||
|
{
|
||||||
|
cert = argv[i+1];
|
||||||
|
i += 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strcmp(argv[i], "-key") == 0 && argv[i+1] != NULL)
|
||||||
|
{
|
||||||
|
private_key = argv[i+1];
|
||||||
|
i += 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
printf("%s:\n"
|
printf("%s:\n"
|
||||||
" [-p [address:]httpport]\n"
|
" [-p [address:]httpport]\n"
|
||||||
" [-s [address:]httpsport]\n"
|
" [-s [address:]httpsport]\n"
|
||||||
|
" [-key private_key]\n"
|
||||||
|
" [-cert cert]\n"
|
||||||
" [-w webroot]\n", argv[0]);
|
" [-w webroot]\n", argv[0]);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -223,10 +241,35 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
addtoservers(active);
|
addtoservers(active);
|
||||||
servers->ssl_ctx = ssl_ctx_new(CONFIG_HTTP_DEFAULT_SSL_OPTIONS,
|
|
||||||
CONFIG_HTTP_SESSION_CACHE_SIZE);
|
if (cert != NULL && private_key != NULL)
|
||||||
|
options |= SSL_NO_DEFAULT_KEY;
|
||||||
|
|
||||||
|
servers->ssl_ctx = ssl_ctx_new(options, CONFIG_HTTP_SESSION_CACHE_SIZE);
|
||||||
servers->is_ssl = 1;
|
servers->is_ssl = 1;
|
||||||
|
|
||||||
|
if (cert != NULL && private_key != NULL)
|
||||||
|
{
|
||||||
|
printf("YEAH\n");
|
||||||
|
if (ssl_obj_load(servers->ssl_ctx, SSL_OBJ_RSA_KEY, private_key,
|
||||||
|
NULL))
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_HTTP_VERBOSE
|
||||||
|
fprintf(stderr, "ERR: Couldn't load private key %s\n", private_key);
|
||||||
|
#endif
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ssl_obj_load(servers->ssl_ctx, SSL_OBJ_X509_CERT, cert,
|
||||||
|
NULL))
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_HTTP_VERBOSE
|
||||||
|
fprintf(stderr, "ERR: Couldn't load cert %s\n", cert);
|
||||||
|
#endif
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_HTTP_HAS_CGI)
|
#if defined(CONFIG_HTTP_HAS_CGI)
|
||||||
addcgiext(CONFIG_HTTP_CGI_EXTENSIONS);
|
addcgiext(CONFIG_HTTP_CGI_EXTENSIONS);
|
||||||
#endif
|
#endif
|
||||||
@ -263,7 +306,6 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
#ifdef CONFIG_HTTP_IS_DAEMON
|
#ifdef CONFIG_HTTP_IS_DAEMON
|
||||||
if (fork() > 0) /* parent will die */
|
if (fork() > 0) /* parent will die */
|
||||||
|
@ -382,7 +382,12 @@ static void do_server(int argc, char *argv[])
|
|||||||
|
|
||||||
if (res > SSL_OK) /* display our interesting output */
|
if (res > SSL_OK) /* display our interesting output */
|
||||||
{
|
{
|
||||||
printf("%s", read_buf);
|
int written = 0;
|
||||||
|
while (written < res)
|
||||||
|
{
|
||||||
|
written += write(STDOUT_FILENO, read_buf+written,
|
||||||
|
res-written);
|
||||||
|
}
|
||||||
TTY_FLUSH();
|
TTY_FLUSH();
|
||||||
}
|
}
|
||||||
else if (res == SSL_CLOSE_NOTIFY)
|
else if (res == SSL_CLOSE_NOTIFY)
|
||||||
@ -711,7 +716,7 @@ static void do_client(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res = ssl_write(ssl, buf, strlen((char *)buf)+1);
|
res = ssl_write(ssl, buf, strlen((char *)buf));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -724,7 +729,12 @@ static void do_client(int argc, char *argv[])
|
|||||||
|
|
||||||
if (res > 0) /* display our interesting output */
|
if (res > 0) /* display our interesting output */
|
||||||
{
|
{
|
||||||
printf("%s", read_buf);
|
int written = 0;
|
||||||
|
while (written < res)
|
||||||
|
{
|
||||||
|
written += write(STDOUT_FILENO, read_buf+written,
|
||||||
|
res-written);
|
||||||
|
}
|
||||||
TTY_FLUSH();
|
TTY_FLUSH();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user