Commit 55e17c84 authored by unknown's avatar unknown

Some new files added for SSL stuff

parent 5a817720
-----BEGIN RSA PRIVATE KEY-----
MIICXgIBAAKBgQDo1FLNTruWFjrwiWuQTNvgMHVaAnJiv+3avgnogNuAVDDWde3j
EKUVRFspkRL+DLd2TelfVlxFPK2ycS1qesu8BIAIdNZ99nxcdts1xPb12NSJn53M
P04/c8E+QX5OCb/qGtmiEw3RDNrY9Ju4VCEXrtezAmGHqQH/9P6cevxnQwIDAQAB
AoGBANxd4cUaaOfkQILbvigE5vMpSlkYCcW3XNv1lJEwLREoHlVNpwuL/IPFf/c2
rWAxDw/1LBYlOg36IXjMMC0g7mRHHoJhdJaFLGdlfclYQvqQ+8JAsAv6UNC63+pn
B5sZOxOuoj7lYN+D9mFVD4qTo3eTUYEOvvmS1j3hCsD2nNNBAkEA+lJUs7Y3KjCF
COZ7XQCkC47rVzkdZ5ey1Z+vVw5SrnUvj6n9i0NEax1jX6JPIhPU7+x90KFkt0ki
pKHd7UQ04wJBAO4caWNnYvmIorCRDy9Q/iAAow5WC6fQlkSlBIe3lRme6Ne8Yxaq
BzlSGYu1ndPkTGEa9PFNNCJm7RtvCBFx8iECQQCkdUzi2Rc7J69vnoV0H8SnN1mU
75hLBBZhVU1MY8OcjK8XsvY59ZLQ0PkFzswwtljS3Ev4suBJrsoM4a+9f29DAkEA
5NTrN3vZc6SrbXLLHBcDUrAqBBIPe4SLlYbdVqzInunILeS/eb2H2b+cC1dMSaHj
AYONmQUwMEuoXTAUmede4QJARK6jEslg/ev8BtMvITP2b6pRCb1w8lOtT5u5Bwnc
NpI3suqSQSQPtRSWQYcdyxrKr2TQEZU7h8R9bVB4b0qAmQ==
-----END RSA PRIVATE KEY-----
-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQCerI3YHZyy/YiWLLpCU/pdvYWK5crTD8ABPPKSRk/ZgK4qic/v
6NRl/Pb1OiZMKdsG+jShh/OXtTyU8YQFrK1XJdkC2wBx4KmqtB0pNl6ppA3yRbmD
dCtF8+IjvOdc5hG29t3ErO1lQiw5RyrJ619FAxCrI7zKXIKat7NtZxjSxwIDAQAB
AoGAA51gudyq1jUKaIlqUNqC6KHJqglkHnzMXfrad9ScOxNAZH2xPADs3cnuglWp
y7BkaftHOarUNM+PKsF5xXtSk5F9UUV+7h2FtPZYUshUgn5hkGZP12otxJMP0cpg
Yt6brQxuOIe/r/Kt5r3nKpp4pyFLX2fGWQq7pSjdkgSZSOECQQDJ9MgbCXd81yde
eo3+YmUPBEQ9d7mivQsyPHMOHLPJKR42N4npdR1zLDBYK5lFzJeQH1y0Uce3O8eL
hM8hkA1XAkEAySKvNTaosbLhShkRazQyQQJYJg0F/93lkQ33ou4crru7Mvi2OZK9
B3BGAmNpSv6ZOZYjM0aE8lGlTaoYJ9GQEQJAGJDyFnfcVQ9G9rMpupv1dxIpyuBZ
cHZWelHoHPtY00txJV80I3Xfkzb42oDTMC5m8V0fRb/870kSSOJq38ZKGQJBAIgq
wxLzfiFPSNYxQmmhXKRGQgcAqh8eylv5aL0VFrX0wjcvya4QeYifqcXUJ2RuGK2z
xwDfrQGf5Jk/njrW1QECQAUofd1l9DLDifRP1j9sjUdwz0fvqQ0o6sbt39PBl1ot
IHdc3nf9z0ft+KOG1CT/M9jYo9SzE9Z6IfwmHxxpY0s=
-----END RSA PRIVATE KEY-----
#include <global.h>
#ifdef HAVE_OPENSSL
#include <my_sys.h>
#include <m_string.h>
#include <m_ctype.h>
#include "mysql.h"
#include "errmsg.h"
#include <my_dir.h>
#ifndef __GNU_LIBRARY__
#define __GNU_LIBRARY__ // Skip warnings in getopt.h
#endif
#include <getopt.h>
#include <signal.h>
#include <violite.h>
const char *VER="0.1";
#ifndef DBUG_OFF
const char *default_dbug_option="d:t:O,-";
#endif
void
fatal_error( const char* r)
{
perror(r);
exit(0);
}
int
main( int argc,
char** argv)
{
char* client_key = 0, *client_cert = 0;
char* ca_file = 0, *ca_path = 0;
struct st_VioSSLConnectorFd* ssl_connector=0;
Vio* client_vio=0;
MY_INIT(argv[0]);
DBUG_PROCESS(argv[0]);
DBUG_PUSH(default_dbug_option);
client_key = "../SSL/client-key.pem";
client_cert = "../SSL/client-cert.pem";
ca_file = "../SSL/cacert.pem";
printf("Client key/cert : %s/%s\n", client_key, client_cert);
if (ca_file!=0)
printf("CAfile : %s\n", ca_file);
if (ca_path!=0)
printf("CApath : %s\n", ca_path);
ssl_connector = new_VioSSLConnectorFd(client_key, client_cert, ca_file, ca_path);
client_vio = (struct st_vio*)my_malloc(sizeof(struct st_vio),MYF(0));
client_vio->vioblocking(client_vio,0);
sslconnect(ssl_connector,client_vio);
{
char xbuf[100];
int r = client_vio->read(client_vio,xbuf, sizeof(xbuf));
if (r<=0) {
my_free((gptr)ssl_connector,MYF(0));
fatal_error("client:SSL_read");
}
xbuf[r] = 0;
printf("client:got %s\n", xbuf);
my_free((gptr)client_vio,MYF(0));
my_free((gptr)ssl_connector,MYF(0));
}
return 0;
}
#else /* HAVE_OPENSSL */
int main() {
return 0;
}
#endif /* HAVE_OPENSSL */
#include <global.h>
#ifdef HAVE_OPENSSL
#include <my_sys.h>
#include <m_string.h>
#include <m_ctype.h>
#include "mysql.h"
#include "errmsg.h"
#include <my_dir.h>
#ifndef __GNU_LIBRARY__
#define __GNU_LIBRARY__ // Skip warnings in getopt.h
#endif
#include <getopt.h>
#include <signal.h>
#include <violite.h>
const char *VER="0.1";
#ifndef DBUG_OFF
const char *default_dbug_option="d:t:O,-";
#endif
void
fatal_error( const char* r)
{
perror(r);
exit(0);
}
int
main( int argc,
char** argv)
{
char* server_key = 0, *server_cert = 0;
char* ca_file = 0, *ca_path = 0;
struct st_VioSSLAcceptorFd* ssl_acceptor=0;
const char* s = "Huhuhuhuuu";
struct sockaddr_in sa_serv;
struct sockaddr_in sa_cli;
int listen_sd;
size_t client_len;
int err;
Vio* client_vio=0, *server_vio=0;
MY_INIT(argv[0]);
DBUG_PROCESS(argv[0]);
DBUG_PUSH(default_dbug_option);
server_key = "../SSL/server-key.pem";
server_cert = "../SSL/server-cert.pem";
ca_file = "../SSL/cacert.pem";
printf("Server key/cert : %s/%s\n", server_key, server_cert);
if (ca_file!=0)
printf("CAfile : %s\n", ca_file);
if (ca_path!=0)
printf("CApath : %s\n", ca_path);
ssl_acceptor = new_VioSSLAcceptorFd(server_key, server_cert, ca_file, ca_path);
server_vio = (struct st_vio*)my_malloc(sizeof(struct st_vio),MYF(0));
/* ----------------------------------------------- */
/* Prepare TCP socket for receiving connections */
listen_sd = socket (AF_INET, SOCK_STREAM, 0);
memset (&sa_serv, '\0', sizeof(sa_serv));
sa_serv.sin_family = AF_INET;
sa_serv.sin_addr.s_addr = INADDR_ANY;
sa_serv.sin_port = htons (1111); /* Server Port number */
err = bind(listen_sd, (struct sockaddr*) &sa_serv,
sizeof (sa_serv));
/* Receive a TCP connection. */
err = listen (listen_sd, 5);
client_len = sizeof(sa_cli);
server_vio->sd = accept (listen_sd, (struct sockaddr*) &sa_cli, &client_len);
close (listen_sd);
printf ("Connection from %lx, port %x\n",
sa_cli.sin_addr.s_addr, sa_cli.sin_port);
/* ----------------------------------------------- */
/* TCP connection is ready. Do server side SSL. */
sslaccept(ssl_acceptor,server_vio);
{
err = server_vio->write(server_vio,(gptr)s, strlen(s));
if (err<=0) {
my_free((gptr)ssl_acceptor,MYF(0));
fatal_error("server:SSL_write");
}
}
my_free((gptr)server_vio,MYF(0));
my_free((gptr)ssl_acceptor,MYF(0));
}
#else /* HAVE_OPENSSL */
int main() {
return 0;
}
#endif /* HAVE_OPENSSL */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment