3 #include "openssl/ssl.h"
\r
7 int main(int argc, char** argv)
\r
12 FILE* fout = stdout;
\r
20 SSL_METHOD* method = 0;
\r
26 WSAStartup(0x0002, &wsd);
\r
30 fin = fopen(argv[1], "r");
\r
34 fout = fopen(argv[2], "w");
\r
38 if (!fin) err_sys("can't open input file");
\r
39 if (!fout) err_sys("can't open output file");
\r
41 tcp_connect(&sockfd);
\r
43 method = SSLv3_client_method();
\r
44 ctx = SSL_CTX_new(method);
\r
46 if (SSL_CTX_load_verify_locations(ctx, caCert, 0) != SSL_SUCCESS)
\r
47 err_sys("can't load ca file");
\r
51 SSL_set_fd(ssl, sockfd);
\r
52 if (SSL_connect(ssl) != SSL_SUCCESS) err_sys("SSL_connect failed");
\r
54 while (fgets(send, sizeof(send), fin)) {
\r
56 int sendSz = strlen(send) + 1;
\r
58 if (SSL_write(ssl, send, sendSz) != sendSz)
\r
59 err_sys("SSL_write failed");
\r
61 if (strncmp(send, "quit", 4) == 0) {
\r
62 fputs("sending server shutdown command: quit!\n", fout);
\r
66 if (SSL_read(ssl, reply, sizeof(reply)) > 0)
\r
75 if (inCreated) fclose(fin);
\r
76 if (outCreated) fclose(fout);
\r
79 closesocket(sockfd);
\r