Skip to content

Commit 5adeacc

Browse files
tniessenxtx1130
authored andcommitted
src: prefer bool over int in crypto_common
PR-URL: nodejs#42097 Reviewed-By: Filip Skokan <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
1 parent 46443b5 commit 5adeacc

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/crypto/crypto_common.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static constexpr int kX509NameFlagsRFC2253WithinUtf8JSON =
5353
~ASN1_STRFLGS_ESC_MSB &
5454
~ASN1_STRFLGS_ESC_CTRL;
5555

56-
int SSL_CTX_get_issuer(SSL_CTX* ctx, X509* cert, X509** issuer) {
56+
bool SSL_CTX_get_issuer(SSL_CTX* ctx, X509* cert, X509** issuer) {
5757
X509_STORE* store = SSL_CTX_get_cert_store(ctx);
5858
DeleteFnPtr<X509_STORE_CTX, X509_STORE_CTX_free> store_ctx(
5959
X509_STORE_CTX_new());
@@ -163,7 +163,8 @@ long VerifyPeerCertificate( // NOLINT(runtime/int)
163163
return err;
164164
}
165165

166-
int UseSNIContext(const SSLPointer& ssl, BaseObjectPtr<SecureContext> context) {
166+
bool UseSNIContext(
167+
const SSLPointer& ssl, BaseObjectPtr<SecureContext> context) {
167168
SSL_CTX* ctx = context->ctx_.get();
168169
X509* x509 = SSL_CTX_get0_certificate(ctx);
169170
EVP_PKEY* pkey = SSL_CTX_get0_privatekey(ctx);
@@ -173,7 +174,7 @@ int UseSNIContext(const SSLPointer& ssl, BaseObjectPtr<SecureContext> context) {
173174
if (err == 1) err = SSL_use_certificate(ssl.get(), x509);
174175
if (err == 1) err = SSL_use_PrivateKey(ssl.get(), pkey);
175176
if (err == 1 && chain != nullptr) err = SSL_set1_chain(ssl.get(), chain);
176-
return err;
177+
return err == 1;
177178
}
178179

179180
const char* GetClientHelloALPN(const SSLPointer& ssl) {

src/crypto/crypto_common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ struct StackOfXASN1Deleter {
2525
};
2626
using StackOfASN1 = std::unique_ptr<STACK_OF(ASN1_OBJECT), StackOfXASN1Deleter>;
2727

28-
int SSL_CTX_get_issuer(SSL_CTX* ctx, X509* cert, X509** issuer);
28+
bool SSL_CTX_get_issuer(SSL_CTX* ctx, X509* cert, X509** issuer);
2929

3030
void LogSecret(
3131
const SSLPointer& ssl,
@@ -59,7 +59,7 @@ long VerifyPeerCertificate( // NOLINT(runtime/int)
5959
const SSLPointer& ssl,
6060
long def = X509_V_ERR_UNSPECIFIED); // NOLINT(runtime/int)
6161

62-
int UseSNIContext(const SSLPointer& ssl, BaseObjectPtr<SecureContext> context);
62+
bool UseSNIContext(const SSLPointer& ssl, BaseObjectPtr<SecureContext> context);
6363

6464
const char* GetClientHelloALPN(const SSLPointer& ssl);
6565

0 commit comments

Comments
 (0)