Skip to content

Commit 3681c4b

Browse files
committed
fixup! src: add additional utilities to crypto::SecureContext
1 parent 72d4b83 commit 3681c4b

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

src/crypto/crypto_context.cc

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -577,9 +577,8 @@ void SecureContext::SetKeylogCallback(KeylogCb cb) {
577577
SSL_CTX_set_keylog_callback(ctx_.get(), cb);
578578
}
579579

580-
Maybe<bool> SecureContext::UseKey(
581-
Environment* env,
582-
std::shared_ptr<KeyObjectData> key) {
580+
Maybe<bool> SecureContext::UseKey(Environment* env,
581+
std::shared_ptr<KeyObjectData> key) {
583582
if (key->GetKeyType() != KeyType::kKeyTypePrivate) {
584583
THROW_ERR_CRYPTO_INVALID_KEYTYPE(env);
585584
return Nothing<bool>();
@@ -693,10 +692,7 @@ Maybe<bool> SecureContext::AddCert(Environment* env, BIOPointer&& bio) {
693692
// confusing, unfortunately.
694693
if (SSL_CTX_use_certificate_chain(
695694
ctx_.get(), std::move(bio), &cert_, &issuer_) != 0) {
696-
ThrowCryptoError(
697-
env,
698-
ERR_get_error(),
699-
"SSL_CTX_use_certificate_chain");
695+
ThrowCryptoError(env, ERR_get_error(), "SSL_CTX_use_certificate_chain");
700696
return Nothing<bool>();
701697
}
702698
return Just(true);
@@ -760,9 +756,9 @@ Maybe<bool> SecureContext::SetCRL(Environment* env, const BIOPointer& bio) {
760756
}
761757

762758
CHECK_EQ(1, X509_STORE_add_crl(cert_store, crl.get()));
763-
CHECK_EQ(1, X509_STORE_set_flags(cert_store,
764-
X509_V_FLAG_CRL_CHECK |
765-
X509_V_FLAG_CRL_CHECK_ALL));
759+
CHECK_EQ(1,
760+
X509_STORE_set_flags(
761+
cert_store, X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL));
766762
return Just(true);
767763
}
768764

src/crypto/crypto_context.h

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ class SecureContext final : public BaseObject {
4747
// Utility method that allows for non-default initialization of
4848
// the SecureContext.
4949
template <typename Func = void(SSLCtxPointer&)>
50-
inline void Initialize(Func fn) { fn(*ctx_); }
50+
inline void Initialize(Func fn) {
51+
fn(*ctx_);
52+
}
5153

5254
SSLPointer CreateSSL();
5355

@@ -59,15 +61,11 @@ class SecureContext final : public BaseObject {
5961
inline const X509Pointer& issuer() const { return issuer_; }
6062
inline const X509Pointer& cert() const { return cert_; }
6163

62-
MUST_USE_RESULT v8::Maybe<bool> AddCert(
63-
Environment* env,
64-
BIOPointer&& bio);
65-
MUST_USE_RESULT v8::Maybe<bool> SetCRL(
66-
Environment* env,
67-
const BIOPointer& bio);
68-
MUST_USE_RESULT v8::Maybe<bool> UseKey(
69-
Environment* env,
70-
std::shared_ptr<KeyObjectData> key);
64+
MUST_USE_RESULT v8::Maybe<bool> AddCert(Environment* env, BIOPointer&& bio);
65+
MUST_USE_RESULT v8::Maybe<bool> SetCRL(Environment* env,
66+
const BIOPointer& bio);
67+
MUST_USE_RESULT v8::Maybe<bool> UseKey(Environment* env,
68+
std::shared_ptr<KeyObjectData> key);
7169
void SetCACert(const BIOPointer& bio);
7270
void SetRootCerts();
7371

0 commit comments

Comments
 (0)