Skip to content

Commit

Permalink
fix(tls) fix type matching (#15224)
Browse files Browse the repository at this point in the history
  • Loading branch information
cirospaciari authored Nov 19, 2024
1 parent f8e9ade commit d19c185
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
5 changes: 3 additions & 2 deletions packages/bun-usockets/src/libusockets.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
#endif

#include "stddef.h"

#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -190,7 +190,8 @@ struct us_socket_context_options_t {
};

struct us_bun_verify_error_t {
long error;
// this is a int64_t because can store a result of BoringSSL.SSL_get_verify_result that uses a long
int64_t error;
const char* code;
const char* reason;
};
Expand Down
2 changes: 1 addition & 1 deletion src/deps/boringssl.translated.zig
Original file line number Diff line number Diff line change
Expand Up @@ -18886,7 +18886,7 @@ pub const CertError = error{
UNKKNOW_CERTIFICATE_VERIFICATION_ERROR,
};

pub fn getCertErrorFromNo(error_no: i32) CertError {
pub fn getCertErrorFromNo(error_no: i64) CertError {
return switch (error_no) {
X509_V_OK => error.OK,
X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT => error.UNABLE_TO_GET_ISSUER_CERT,
Expand Down
7 changes: 4 additions & 3 deletions src/deps/uws.zig
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ pub const InternalLoopData = extern struct {

pub const UpgradedDuplex = struct {
pub const CertError = struct {
error_no: i32 = 0,
error_no: i64 = 0,
code: [:0]const u8 = "",
reason: [:0]const u8 = "",

Expand Down Expand Up @@ -1700,7 +1700,7 @@ pub fn NewSocketHandler(comptime is_ssl: bool) type {
return this.getError() != 0;
}

pub fn getError(this: ThisSocket) i32 {
pub fn getError(this: ThisSocket) i64 {
switch (this.socket) {
.connected => |socket| {
return us_socket_get_error(
Expand Down Expand Up @@ -2643,7 +2643,8 @@ pub const create_bun_socket_error_t = enum(i32) {
};

pub const us_bun_verify_error_t = extern struct {
error_no: i32 = 0,
// this is a i64 because can store a result of BoringSSL.SSL_get_verify_result that uses a long
error_no: i64 = 0,
code: [*c]const u8 = null,
reason: [*c]const u8 = null,
};
Expand Down
4 changes: 2 additions & 2 deletions src/http.zig
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ const ProxyTunnel = struct {
this.state.request_stage = .proxy_headers;
this.state.request_sent_len = 0;
const handshake_error = HTTPCertError{
.error_no = ssl_error.error_no,
.error_no = @intCast(ssl_error.error_no),
.code = if (ssl_error.code == null) "" else ssl_error.code[0..bun.len(ssl_error.code) :0],
.reason = if (ssl_error.code == null) "" else ssl_error.reason[0..bun.len(ssl_error.reason) :0],
};
Expand Down Expand Up @@ -511,7 +511,7 @@ const ProxyTunnel = struct {
};

pub const HTTPCertError = struct {
error_no: i32 = 0,
error_no: i64 = 0,
code: [:0]const u8 = "",
reason: [:0]const u8 = "",
};
Expand Down

0 comments on commit d19c185

Please sign in to comment.