mirror of
https://github.com/guanzhi/GmSSL.git
synced 2026-05-07 00:46:17 +08:00
Support domain name in SSL clients
This commit is contained in:
@@ -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>
|
||||
@@ -79,6 +80,7 @@ int tlcp_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;
|
||||
@@ -131,15 +133,18 @@ bad:
|
||||
fprintf(stderr, "%s: '-in' option required\n", prog);
|
||||
return -1;
|
||||
}
|
||||
if (!(hp = gethostbyname(host))) {
|
||||
herror("tlcp_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);
|
||||
|
||||
|
||||
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
|
||||
fprintf(stderr, "%s: open socket error : %s\n", prog, strerror(errno));
|
||||
goto end;
|
||||
|
||||
@@ -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 tls12_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("tls12_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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user