summaryrefslogtreecommitdiffstats
path: root/tests/pytests/rehandshake/tlsproxy.c
blob: 0c074f1ed10e27519e2be5acf6138b13490ac5b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <stdio.h>
#include "tls-proxy.h"
#include <gnutls/gnutls.h>

int main()
{
	struct tls_proxy_ctx *proxy = tls_proxy_allocate();
	if (!proxy) {
		fprintf(stderr, "can't allocate tls_proxy structure\n");
		return 1;
	}
	int res = tls_proxy_init(proxy,
				 "127.0.0.1", 53921, /* Address to listen */
				 "127.0.0.1", 53910, /* Upstream address */
				 "../certs/tt.cert.pem",
				 "../certs/tt.key.pem");
	if (res) {
		fprintf(stderr, "can't initialize tls_proxy structure\n");
		return res;
	}
	res = tls_proxy_start_listen(proxy);
	if (res) {
		fprintf(stderr, "error starting listen, error code: %i\n", res);
		return res;
	}
	fprintf(stdout, "started...\n");
	res = tls_proxy_run(proxy);
	tls_proxy_free(proxy);
	return res;
}