Skip to content

Commit 503ed9f

Browse files
Hiroshi HatakeVanessa Zhang
authored andcommitted
tls: introduce API for TLS version and cipher settings
Adds backend API hooks `set_minmax_proto` and `set_ciphers`, and utility functions `flb_tls_set_minmax_proto()` and `flb_tls_set_ciphers()` for applying TLS constraints. Signed-off-by: Eduardo Silva <[email protected]>
1 parent a2373d5 commit 503ed9f

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

include/fluent-bit/tls/flb_tls.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ struct flb_tls_backend {
7777
/* Additional settings */
7878
int (*context_alpn_set) (void *, const char *);
7979

80+
/* TLS Protocol version */
81+
int (*set_minmax_proto) (struct flb_tls *tls, const char *, const char *);
82+
/* TLS Ciphers */
83+
int (*set_ciphers) (struct flb_tls *tls, const char *);
84+
8085
/* Session management */
8186
void *(*session_create) (struct flb_tls *, int);
8287
int (*session_destroy) (void *);
@@ -119,6 +124,9 @@ int flb_tls_set_alpn(struct flb_tls *tls, const char *alpn);
119124
int flb_tls_set_verify_hostname(struct flb_tls *tls, int verify_hostname);
120125

121126
int flb_tls_load_system_certificates(struct flb_tls *tls);
127+
int flb_tls_set_minmax_proto(struct flb_tls *tls,
128+
const char *min_version, const char *max_version);
129+
int flb_tls_set_ciphers(struct flb_tls *tls, const char *ciphers);
122130

123131
struct mk_list *flb_tls_get_config_map(struct flb_config *config);
124132

src/tls/flb_tls.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,24 @@ struct flb_config_map tls_configmap[] = {
8080
"Enable or disable to verify hostname"
8181
},
8282

83+
{
84+
FLB_CONFIG_MAP_STR, "tls.min_version", NULL,
85+
0, FLB_FALSE, 0,
86+
"Specify the minimum version of TLS"
87+
},
88+
89+
{
90+
FLB_CONFIG_MAP_STR, "tls.max_version", NULL,
91+
0, FLB_FALSE, 0,
92+
"Specify the maximum version of TLS"
93+
},
94+
95+
{
96+
FLB_CONFIG_MAP_STR, "tls.ciphers", NULL,
97+
0, FLB_FALSE, 0,
98+
"Specify TLS ciphers up to TLSv1.2"
99+
},
100+
83101
/* EOF */
84102
{0}
85103
};
@@ -209,6 +227,25 @@ struct flb_tls *flb_tls_create(int mode,
209227
return tls;
210228
}
211229

230+
int flb_tls_set_minmax_proto(struct flb_tls *tls,
231+
const char *min_version, const char *max_version)
232+
{
233+
if (tls->ctx) {
234+
return tls->api->set_minmax_proto(tls, min_version, max_version);
235+
}
236+
237+
return 0;
238+
}
239+
240+
int flb_tls_set_ciphers(struct flb_tls *tls, const char *ciphers)
241+
{
242+
if (tls->ctx) {
243+
return tls->api->set_ciphers(tls, ciphers);
244+
}
245+
246+
return 0;
247+
}
248+
212249
int flb_tls_init()
213250
{
214251
return tls_init();

0 commit comments

Comments
 (0)