Skip to content

Commit

Permalink
feat: removed the depenedncy on the idevid CA cert
Browse files Browse the repository at this point in the history
  • Loading branch information
mereacre committed Jan 23, 2024
1 parent 7568296 commit ee15111
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/brski/brski.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,7 @@ int main(int argc, char *argv[]) {
}

case CommandId::COMMAND_START_REGISTRAR:
if (registrar_start(&config.rconf, &config.mconf, &config.pconf,
&rcontext) < 0) {
if (registrar_start(&config.rconf, &config.mconf, &rcontext) < 0) {
log_error("https_start fail");
return EXIT_FAILURE;
}
Expand Down
11 changes: 11 additions & 0 deletions src/brski/http/httplib.h
Original file line number Diff line number Diff line change
Expand Up @@ -8872,6 +8872,13 @@ static SSLInit sslinit_;

} // namespace detail

// Accepty the client certificate as it is, vrefication not needed
int SSL_verify_fn(int preverify_ok, X509_STORE_CTX *x509_ctx) {
(void) preverify_ok;
(void) x509_ctx;
return 1;
}

// SSL HTTP server implementation
inline SSLServer::SSLServer(const char *cert_path, const char *private_key_path,
const char *client_ca_cert_file_path,
Expand Down Expand Up @@ -8905,6 +8912,10 @@ inline SSLServer::SSLServer(const char *cert_path, const char *private_key_path,
SSL_CTX_set_verify(
ctx_, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, nullptr);
}

if (client_ca_cert_file_path == nullptr && client_ca_cert_dir_path == nullptr) {
SSL_CTX_set_verify(ctx_, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT, SSL_verify_fn);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/brski/registrar/registrar_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ int registrar_requestvoucher(const RequestHeader &request_header,
char *serial_number = NULL;
const char *cms_str = request_body.c_str();

log_trace("registrar_requestvoucher:");
log_trace("registrar_requestvoucher: %p", peer_certificate);
response_header["Content-Type"] = "application/voucher-cms+json";

struct CrypoCertMeta : public crypto_cert_meta {
Expand Down
4 changes: 1 addition & 3 deletions src/brski/registrar/registrar_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ void setup_registrar_routes(std::vector<struct RouteTuple> &routes) {
}

int registrar_start(struct registrar_config *rconf, struct masa_config *mconf,
struct pledge_config *pconf,
struct RegistrarContext **context) {
std::vector<struct RouteTuple> routes;

Expand All @@ -64,8 +63,7 @@ int registrar_start(struct registrar_config *rconf, struct masa_config *mconf,
.port = rconf->port,
.tls_cert_path = rconf->tls_cert_path,
.tls_key_path = rconf->tls_key_path,
.client_ca_cert_path =
pconf->idevid_ca_cert_path};
.client_ca_cert_path = nullptr};

return https_start(&hconf, routes, static_cast<void *>(*context),
&(*context)->srv_ctx);
Expand Down
2 changes: 0 additions & 2 deletions src/brski/registrar/registrar_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@
*
* @param[in] rconf The registrar config
* @param[in] mconf The masa config
* @param[in] pconf The pledge config
* @param[out] context The registrar context
* @return int 0 on success, -1 on failure
*/
int registrar_start(struct registrar_config *rconf, struct masa_config *mconf,
struct pledge_config *pconf,
struct RegistrarContext **context);

/**
Expand Down

0 comments on commit ee15111

Please sign in to comment.