Continuing trying to crunch android openssl sizes.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4738 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2024-01-06 21:33:20 +00:00
parent 32ebfa78cd
commit b73f5011cf
10 changed files with 267 additions and 5 deletions

View File

@ -33,8 +33,7 @@ tf_tls_context_t* tf_tls_context_create()
{
tf_tls_context_t* context = tf_malloc(sizeof(tf_tls_context_t));
memset(context, 0, sizeof(*context));
SSL_library_init();
SSL_load_error_strings();
OPENSSL_init_ssl(0, NULL);
context->context = SSL_CTX_new(SSLv23_method());
SSL_CTX_set_default_verify_paths(context->context);
return context;
@ -166,9 +165,10 @@ void tf_tls_session_shutdown(tf_tls_session_t* session)
int tf_tls_session_get_peer_certificate(tf_tls_session_t* session, char* buffer, size_t bytes)
{
int result = -1;
X509* certificate = SSL_get_peer_certificate(session->ssl);
X509* certificate = SSL_get1_peer_certificate(session->ssl);
BIO* bio = BIO_new(BIO_s_mem());
PEM_write_bio_X509(bio, certificate);
X509_free(certificate);
BUF_MEM* mem;
BIO_get_mem_ptr(bio, &mem);
if (mem->length <= bytes)
@ -269,7 +269,7 @@ static bool _tls_session_verify_hostname(X509* certificate, const char* hostname
static bool _tls_session_verify_peer_certificate(tf_tls_session_t* session)
{
bool verified = false;
X509* certificate = SSL_get_peer_certificate(session->ssl);
X509* certificate = SSL_get1_peer_certificate(session->ssl);
if (certificate)
{
if (SSL_get_verify_result(session->ssl) == X509_V_OK)