4 static gnutls_dh_params_t dhParameters;
5 static gnutls_certificate_credentials certificate;
7 void initiliazeCertificate()
9 char* certificatePath = (char*) getStrConf(CERTIFICATE);
11 if(!certificatePath) {
12 Log_fatal("No certificate file specified.");
15 char* keyPath = (char*) getStrConf(KEY);
18 Log_fatal("No key file specified");
21 gnutls_certificate_allocate_credentials(&certificate);
23 int error = gnutls_certificate_set_x509_key_file(certificate, certificatePath, keyPath, GNUTLS_X509_FMT_PEM);
25 if( error != GNUTLS_E_SUCCESS ) {
26 Log_fatal("Could not open key (%s) or certificate (%s).", keyPath, certificatePath);
33 unsigned const bitCount = gnutls_sec_param_to_pk_bits(GNUTLS_PK_DH, GNUTLS_SEC_PARAM_MEDIUM);
35 gnutls_dh_params_init(&dhParameters);
36 gnutls_dh_params_generate2(dhParameters, bitCount);
38 #if GNUTLS_VERSION_NUMBER < 0x030300
42 initializeCertificate();
44 Log_info("Sucessfully initialized GNUTLS version %s", gnutls_check_version(NULL));