+ RSA_free(rsa);
+ BN_free(bne);
+}
+
+
+// Set the private key and certificate chain for the global SSL Context.
+// This is called during initialization, and can be called again later if the certificate changes.
+void bind_to_key_and_certificate(void) {
+
+ syslog(LOG_DEBUG, "crypto: using certificate chain %s", file_crpt_file_cer);
+ SSL_CTX_use_certificate_chain_file(ssl_ctx, file_crpt_file_cer);
+
+ syslog(LOG_DEBUG, "crypto: using private key %s", file_crpt_file_key);
+ SSL_CTX_use_PrivateKey_file(ssl_ctx, file_crpt_file_key, SSL_FILETYPE_PEM);
+ if ( !SSL_CTX_check_private_key(ssl_ctx) ) {
+ syslog(LOG_ERR, "crypto: cannot install certificate: %s", ERR_reason_error_string(ERR_get_error()));
+ }