1
/* Copyright (C) 2000 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
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
DBUG_ENTER("do_ssl_stuff");
57
server_vio = vio_new(args->sd, VIO_TYPE_TCPIP, TRUE);
59
/* ----------------------------------------------- */
60
/* TCP connection is ready. Do server side SSL. */
62
err = write(server_vio->sd,(uchar*)s, strlen(s));
63
sslaccept(args->ssl_acceptor,server_vio,60L);
64
err = server_vio->write(server_vio,(uchar*)s, strlen(s));
69
client_thread( void* arg)
72
do_ssl_stuff((TH_ARGS*)arg);
77
main(int argc __attribute__((unused)), char** argv)
79
char server_key[] = "../SSL/server-key.pem",
80
server_cert[] = "../SSL/server-cert.pem";
81
char ca_file[] = "../SSL/cacert.pem",
84
struct st_VioSSLFd* ssl_acceptor;
89
struct sockaddr_in sa_serv;
90
struct sockaddr_in sa_cli;
93
size_socket client_len;
94
int reuseaddr = 1; /* better testing, uh? */
97
DBUG_PROCESS(argv[0]);
98
DBUG_PUSH(default_dbug_option);
100
printf("Server key/cert : %s/%s\n", server_key, server_cert);
103
printf("CAfile : %s\n", ca_file);
105
printf("CApath : %s\n", ca_path);
107
th_args.ssl_acceptor = ssl_acceptor = new_VioSSLAcceptorFd(server_key, server_cert, ca_file, ca_path,cipher);
109
/* ----------------------------------------------- */
110
/* Prepare TCP socket for receiving connections */
112
listen_sd = socket (AF_INET, SOCK_STREAM, 0);
113
setsockopt(listen_sd, SOL_SOCKET, SO_REUSEADDR, &reuseaddr, sizeof(&reuseaddr));
115
memset (&sa_serv, '\0', sizeof(sa_serv));
116
sa_serv.sin_family = AF_INET;
117
sa_serv.sin_addr.s_addr = INADDR_ANY;
118
sa_serv.sin_port = htons (1111); /* Server Port number */
120
err = bind(listen_sd, (struct sockaddr*) &sa_serv,
123
/* Receive a TCP connection. */
125
err = listen (listen_sd, 5);
126
client_len = sizeof(sa_cli);
127
th_args.sd = accept (listen_sd, (struct sockaddr*) &sa_cli, &client_len);
130
printf ("Connection from %lx, port %x\n",
131
(long)sa_cli.sin_addr.s_addr, sa_cli.sin_port);
133
/* ----------------------------------------------- */
134
/* TCP connection is ready. Do server side SSL. */
136
err = pthread_create(&th, NULL, client_thread, (void*)&th_args);
137
DBUG_PRINT("info", ("pthread_create: %d", err));
138
pthread_join(th, NULL);
142
my_free((uchar*)ssl_acceptor,MYF(0));
143
fatal_error("server:SSL_write");
147
my_free((uchar*)ssl_acceptor,MYF(0));
150
#else /* HAVE_OPENSSL */
155
#endif /* HAVE_OPENSSL */