Subversion Repositories Tewi

Rev

Rev 20 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 20 Rev 31
Line 1... Line 1...
1
/* $Id: ssl.c 20 2024-09-14 09:59:15Z nishi $ */
1
/* $Id: ssl.c 31 2024-09-16 07:52:02Z nishi $ */
2
 
2
 
3
#define SOURCE
3
#define SOURCE
4
 
4
 
5
#include "tw_ssl.h"
5
#include "tw_ssl.h"
6
 
6
 
Line 18... Line 18...
18
		cm_log("SSL", "Certificate request for %s", s);
18
		cm_log("SSL", "Certificate request for %s", s);
19
	} else {
19
	} else {
20
		s = config.hostname;
20
		s = config.hostname;
21
		cm_log("SSL", "Could not get the servername, defaulting to the hostname: %s", s);
21
		cm_log("SSL", "Could not get the servername, defaulting to the hostname: %s", s);
22
	}
22
	}
23
	struct tw_config_entry* e = tw_vhost_match(s, (uint64_t)arg);
23
	struct tw_config_entry* e = tw_vhost_match(s, (__UINTPTR_TYPE__)arg);
24
	if(e != NULL && e->sslkey != NULL && e->sslcert != NULL) {
24
	if(e != NULL && e->sslkey != NULL && e->sslcert != NULL) {
25
		SSL_use_PrivateKey_file(ssl, e->sslkey, SSL_FILETYPE_PEM);
25
		SSL_use_PrivateKey_file(ssl, e->sslkey, SSL_FILETYPE_PEM);
26
		SSL_use_certificate_file(ssl, e->sslcert, SSL_FILETYPE_PEM);
26
		SSL_use_certificate_file(ssl, e->sslcert, SSL_FILETYPE_PEM);
27
		return 1;
27
		return 1;
28
	} else if(config.root.sslkey != NULL && config.root.sslcert != NULL) {
28
	} else if(config.root.sslkey != NULL && config.root.sslcert != NULL) {
Line 32... Line 32...
32
	} else {
32
	} else {
33
		return 0;
33
		return 0;
34
	}
34
	}
35
}
35
}
36
 
36
 
37
SSL_CTX* tw_create_ssl_ctx(uint64_t port) {
37
SSL_CTX* tw_create_ssl_ctx(__UINTPTR_TYPE__ port) {
38
	SSL_CTX* ctx = SSL_CTX_new(TLS_server_method());
38
	SSL_CTX* ctx = SSL_CTX_new(TLS_server_method());
39
	SSL_CTX_set_cert_cb(ctx, tw_ssl_cert_cb, (void*)port);
39
	SSL_CTX_set_cert_cb(ctx, tw_ssl_cert_cb, (void*)port);
40
	return ctx;
40
	return ctx;
41
}
41
}