Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixup! tls: add allowPartialTrustChain flag
  • Loading branch information
addaleax committed Sep 5, 2024
commit 509156ac75aed153b3deab72b33eec6c3e6efe17
4 changes: 2 additions & 2 deletions src/crypto/crypto_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -761,15 +761,15 @@ void SecureContext::SetX509StoreFlag(unsigned long flags) {
}

X509_STORE* SecureContext::GetCertStoreOwnedByThisSecureContext() {
if (owned_cert_store_cached_ != nullptr) return owned_cert_store_cached_;
if (own_cert_store_cache_ != nullptr) return own_cert_store_cache_;

X509_STORE* cert_store = SSL_CTX_get_cert_store(ctx_.get());
if (cert_store == GetOrCreateRootCertStore()) {
cert_store = NewRootCertStore();
SSL_CTX_set_cert_store(ctx_.get(), cert_store);
}

return owned_cert_store_cached_ = cert_store;
return own_cert_store_cache_ = cert_store;
}

void SecureContext::SetAllowPartialTrustChain(
Expand Down
3 changes: 2 additions & 1 deletion src/crypto/crypto_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ class SecureContext final : public BaseObject {
SSLCtxPointer ctx_;
X509Pointer cert_;
X509Pointer issuer_;
X509_STORE* owned_cert_store_cached_ = nullptr;
// Non-owning cache for SSL_CTX_get_cert_store(ctx_.get())
X509_STORE* own_cert_store_cache_ = nullptr;
#ifndef OPENSSL_NO_ENGINE
bool client_cert_engine_provided_ = false;
ncrypto::EnginePointer private_key_engine_;
Expand Down
8 changes: 3 additions & 5 deletions test/parallel/test-tls-client-allow-partial-trust-chain.js
Comment thread
addaleax marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
'use strict';
const common = require('../common');

if (!common.hasCrypto)
common.skip('missing crypto');
if (!common.hasCrypto) { common.skip('missing crypto'); };

const assert = require('assert');
const { once } = require('events');
const tls = require('tls');
const fixtures = require('../common/fixtures');

// agent6-cert.pem is signed by intermediate cert of ca3.
// The server has a cert chain of agent6->ca3->ca1(root).

const { it, beforeEach, afterEach, describe } = require('node:test');

describe('allowPartialTrustChain', function() {
describe('allowPartialTrustChain', { skip: !common.hasCrypto }, function() {
const tls = require('tls');
let server;
let client;
let opts;
Expand Down