Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support mbedtls 3.0.0 #10

Open
Coder666 opened this issue Aug 18, 2021 · 2 comments
Open

Support mbedtls 3.0.0 #10

Coder666 opened this issue Aug 18, 2021 · 2 comments

Comments

@Coder666
Copy link

I've successfully compiled this library against mbedtls 3.0.0 however a couple of very minor changes are required:

certs.h does not exist in 3.0.0

Config.hpp
...
...
#ifndef oatpp_mbedtls_Config_hpp
#define oatpp_mbedtls_Config_hpp

#include "mbedtls/entropy.h"
#include "mbedtls/ctr_drbg.h"
#if MBEDTLS_VERSION_MAJOR < 3
#include "mbedtls/certs.h"
#endif
#include "mbedtls/x509.h"
#include "mbedtls/ssl.h"
...
...

mbedtls_pk_parse_keyfile requires a rng

Config.cpp

...
...
...
std::shared_ptr<Config> Config::createDefaultServerConfigShared(const char* serverCertFile, const char* privateKeyFile, const char* pkPassword) {

  auto result = createShared();

#if defined(OATPP_MBEDTLS_DEBUG)
  mbedtls_ssl_conf_dbg( &result->m_config, mbedtlsDebug, (void*)"Server" );
  mbedtls_debug_set_threshold( OATPP_MBEDTLS_DEBUG );
#endif

  auto res = mbedtls_x509_crt_parse_file(&result->m_srvcert, serverCertFile);
  if(res != 0) {
    OATPP_LOGD("[oatpp::mbedtls::Config::createDefaultServerConfigShared()]", "Error. Can't parse serverCertFile path='%s', return value=%d", serverCertFile, res);
    throw std::runtime_error("[oatpp::mbedtls::Config::createDefaultServerConfigShared()]: Error. Can't parse serverCertFile");
  }

#if MBEDTLS_VERSION_MAJOR >= 3
  res = mbedtls_pk_parse_keyfile(&result->m_privateKey, privateKeyFile, pkPassword, mbedtls_ctr_drbg_random, &result->m_ctr_drbg);
#else
  res = mbedtls_pk_parse_keyfile(&result->m_privateKey, privateKeyFile, pkPassword);
#endif
  if(res != 0)
...
...
...

NOTE: I haven't yet tested this, only got the build working.

Is support for mbedtls 3.0.0 something that could be added into the library?

@bamkrs
Copy link
Member

bamkrs commented Aug 18, 2021

Hey @Coder666 !
Extending the support to a broader range of supported versions is always good! We would be grateful if you could contribute a PR when your changes have proven themselves to be functional. 🥳

@dg0yt
Copy link

dg0yt commented Aug 29, 2024

Three years later, this is the last blocker for updating mbedtls in vcpkg.
With no updates in two years, it is probably okay to simply skip oatmpp-mbedtls in vcpkg CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants