Support domain name in SSL clients

This commit is contained in:
Zhi Guan
2022-07-27 19:10:02 +08:00
parent cda0fae675
commit f1da2d5528
5 changed files with 21 additions and 2701 deletions

View File

@@ -52,6 +52,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <netdb.h>
#include <sys/types.h>
#include <arpa/inet.h>
#include <sys/socket.h>
@@ -81,6 +82,7 @@ int tls13_client_main(int argc, char *argv[])
char *certfile = NULL;
char *keyfile = NULL;
char *pass = NULL;
struct hostent *hp;
struct sockaddr_in server;
int sock;
TLS_CTX ctx;
@@ -133,11 +135,15 @@ bad:
fprintf(stderr, "%s: '-in' option required\n", prog);
return -1;
}
if (!(hp = gethostbyname(host))) {
herror("tls13_client: '-host' invalid");
goto end;
}
memset(&ctx, 0, sizeof(ctx));
memset(&conn, 0, sizeof(conn));
server.sin_addr.s_addr = inet_addr(host);
server.sin_addr = *((struct in_addr *)hp->h_addr_list[0]);
server.sin_family = AF_INET;
server.sin_port = htons(port);