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,-";
36
fatal_error( const char* r)
43
main( int argc __attribute__((unused)),
46
char client_key[] = "../SSL/client-key.pem", client_cert[] = "../SSL/client-cert.pem";
47
char ca_file[] = "../SSL/cacert.pem", *ca_path = 0, *cipher=0;
48
struct st_VioSSLFd* ssl_connector= 0;
49
struct sockaddr_in sa;
52
char xbuf[100]="Ohohhhhoh1234";
54
DBUG_PROCESS(argv[0]);
55
DBUG_PUSH(default_dbug_option);
57
printf("Client key/cert : %s/%s\n", client_key, client_cert);
59
printf("CAfile : %s\n", ca_file);
61
printf("CApath : %s\n", ca_path);
63
ssl_connector = new_VioSSLConnectorFd(client_key, client_cert, ca_file, ca_path, cipher);
65
fatal_error("client:new_VioSSLConnectorFd failed");
68
/* ----------------------------------------------- */
69
/* Create a socket and connect to server using normal socket calls. */
71
client_vio = vio_new(socket (AF_INET, SOCK_STREAM, 0), VIO_TYPE_TCPIP, TRUE);
73
memset (&sa, '\0', sizeof(sa));
74
sa.sin_family = AF_INET;
75
sa.sin_addr.s_addr = inet_addr ("127.0.0.1"); /* Server IP */
76
sa.sin_port = htons (1111); /* Server Port number */
78
err = connect(client_vio->sd, (struct sockaddr*) &sa,
81
/* ----------------------------------------------- */
82
/* Now we have TCP conncetion. Start SSL negotiation. */
83
read(client_vio->sd,xbuf, sizeof(xbuf));
84
sslconnect(ssl_connector,client_vio,60L);
85
err = vio_read(client_vio,xbuf, sizeof(xbuf));
87
my_free((uchar*)ssl_connector,MYF(0));
88
fatal_error("client:SSL_read");
91
printf("client:got %s\n", xbuf);
92
my_free((uchar*)client_vio,MYF(0));
93
my_free((uchar*)ssl_connector,MYF(0));
96
#else /* HAVE_OPENSSL */
101
#endif /* HAVE_OPENSSL */