Skip to content

Commit 97f5ced

Browse files
tniessensxa
authored andcommitted
src: prefer bool over int in crypto_common
PR-URL: #42097 Reviewed-By: Filip Skokan <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Darshan Sen <[email protected]>
1 parent 382ffda commit 97f5ced

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/crypto/crypto_common.cc

+4-3
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ static constexpr int kX509NameFlagsMultiline =
4949
XN_FLAG_SEP_MULTILINE |
5050
XN_FLAG_FN_SN;
5151

52-
int SSL_CTX_get_issuer(SSL_CTX* ctx, X509* cert, X509** issuer) {
52+
bool SSL_CTX_get_issuer(SSL_CTX* ctx, X509* cert, X509** issuer) {
5353
X509_STORE* store = SSL_CTX_get_cert_store(ctx);
5454
DeleteFnPtr<X509_STORE_CTX, X509_STORE_CTX_free> store_ctx(
5555
X509_STORE_CTX_new());
@@ -159,7 +159,8 @@ long VerifyPeerCertificate( // NOLINT(runtime/int)
159159
return err;
160160
}
161161

162-
int UseSNIContext(const SSLPointer& ssl, BaseObjectPtr<SecureContext> context) {
162+
bool UseSNIContext(
163+
const SSLPointer& ssl, BaseObjectPtr<SecureContext> context) {
163164
SSL_CTX* ctx = context->ctx_.get();
164165
X509* x509 = SSL_CTX_get0_certificate(ctx);
165166
EVP_PKEY* pkey = SSL_CTX_get0_privatekey(ctx);
@@ -169,7 +170,7 @@ int UseSNIContext(const SSLPointer& ssl, BaseObjectPtr<SecureContext> context) {
169170
if (err == 1) err = SSL_use_certificate(ssl.get(), x509);
170171
if (err == 1) err = SSL_use_PrivateKey(ssl.get(), pkey);
171172
if (err == 1 && chain != nullptr) err = SSL_set1_chain(ssl.get(), chain);
172-
return err;
173+
return err == 1;
173174
}
174175

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

src/crypto/crypto_common.h

+2-2
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)