]> mj.ucw.cz Git - eval.git/blob - submit/submitd.c
First attempts at using gnutls.
[eval.git] / submit / submitd.c
1 #include "lib/lib.h"
2
3 #include <gnutls/gnutls.h>
4
5 static gnutls_certificate_credentials_t cert_cred;
6
7 int main(void)
8 {
9   int err;
10
11   gnutls_global_init();
12   err = gnutls_certificate_allocate_credentials(&cert_cred);
13   if (err)
14     die("Unable to allocate credentials: %s", gnutls_strerror(err));
15   err = gnutls_certificate_set_x509_trust_file(cert_cred, "ca-cert.pem", GNUTLS_X509_FMT_PEM);
16   if (!err)
17     die("No CA certificate found");
18   if (err < 0)
19     die("Unable to load X509 trust file: %s", gnutls_strerror(err));
20   err = gnutls_certificate_set_x509_key_file(cert_cred, "server-cert.pem", "server-key.pem", GNUTLS_X509_FMT_PEM);
21   if (err < 0)
22     die("Unable to load X509 key file: %s", gnutls_strerror(err));
23
24   gnutls_global_deinit();
25   return 0;
26 }