16 #include <my_global.h>
24 #include <my_getopt.h>
28 const char *VER=
"0.2";
32 const char *default_dbug_option=
"d:t:O,-";
37 fatal_error(
const char* r)
46 struct st_VioSSLFd* ssl_acceptor;
50 do_ssl_stuff( TH_ARGS* args)
52 const char* s =
"Huhuhuhuuu";
55 unsigned long ssl_error;
56 DBUG_ENTER(
"do_ssl_stuff");
58 server_vio = vio_new(args->sd, VIO_TYPE_TCPIP, TRUE);
63 err = write(server_vio->sd,(uchar*)s, strlen(s));
64 sslaccept(args->ssl_acceptor,server_vio,60L,&ssl_error);
65 err = server_vio->write(server_vio,(uchar*)s, strlen(s));
70 client_thread(
void* arg)
73 do_ssl_stuff((TH_ARGS*)arg);
78 main(
int argc __attribute__((unused)),
char** argv)
80 char server_key[] =
"../SSL/server-key.pem",
81 server_cert[] =
"../SSL/server-cert.pem";
82 char ca_file[] =
"../SSL/cacert.pem",
85 struct st_VioSSLFd* ssl_acceptor;
90 struct sockaddr_in sa_serv;
91 struct sockaddr_in sa_cli;
94 size_socket client_len;
98 DBUG_PROCESS(argv[0]);
99 DBUG_PUSH(default_dbug_option);
101 printf(
"Server key/cert : %s/%s\n", server_key, server_cert);
104 printf(
"CAfile : %s\n", ca_file);
106 printf(
"CApath : %s\n", ca_path);
108 th_args.ssl_acceptor = ssl_acceptor = new_VioSSLAcceptorFd(server_key, server_cert, ca_file, ca_path,cipher);
113 listen_sd = socket (AF_INET, SOCK_STREAM, 0);
114 setsockopt(listen_sd, SOL_SOCKET, SO_REUSEADDR, &reuseaddr,
sizeof(&reuseaddr));
116 memset (&sa_serv,
'\0',
sizeof(sa_serv));
117 sa_serv.sin_family = AF_INET;
118 sa_serv.sin_addr.s_addr = INADDR_ANY;
119 sa_serv.sin_port = htons (1111);
121 err = bind(listen_sd, (
struct sockaddr*) &sa_serv,
126 err = listen (listen_sd, 5);
127 client_len =
sizeof(sa_cli);
128 th_args.sd = accept (listen_sd, (
struct sockaddr*) &sa_cli, &client_len);
131 printf (
"Connection from %lx, port %x\n",
132 (
long)sa_cli.sin_addr.s_addr, sa_cli.sin_port);
137 err = pthread_create(&th, NULL, client_thread, (
void*)&th_args);
138 DBUG_PRINT(
"info", (
"pthread_create: %d", err));
139 pthread_join(th, NULL);
143 my_free(ssl_acceptor);
144 fatal_error(
"server:SSL_write");
148 my_free(ssl_acceptor);