@@ -65,59 +65,71 @@ struct s2n_ctx {
65
65
struct s2n_config * s2n_config ;
66
66
};
67
67
68
+ AWS_STATIC_STRING_FROM_LITERAL (s_debian_path , "/etc/ssl/certs" );
69
+ AWS_STATIC_STRING_FROM_LITERAL (s_rhel_path , "/etc/pki/tls/certs" );
70
+ AWS_STATIC_STRING_FROM_LITERAL (s_android_path , "/system/etc/security/cacerts" );
71
+ AWS_STATIC_STRING_FROM_LITERAL (s_free_bsd_path , "/usr/local/share/certs" );
72
+ AWS_STATIC_STRING_FROM_LITERAL (s_net_bsd_path , "/etc/openssl/certs" );
73
+
68
74
static const char * s_determine_default_pki_dir (void ) {
69
75
/* debian variants */
70
- if (aws_path_exists ("/etc/ssl/certs" )) {
71
- return "/etc/ssl/certs" ;
76
+ if (aws_path_exists (s_debian_path )) {
77
+ return aws_string_c_str ( s_debian_path ) ;
72
78
}
73
79
74
80
/* RHEL variants */
75
- if (aws_path_exists ("/etc/pki/tls/certs" )) {
76
- return "/etc/pki/tls/certs" ;
81
+ if (aws_path_exists (s_rhel_path )) {
82
+ return aws_string_c_str ( s_rhel_path ) ;
77
83
}
78
84
79
85
/* android */
80
- if (aws_path_exists ("/system/etc/security/cacerts" )) {
81
- return "/system/etc/security/cacerts" ;
86
+ if (aws_path_exists (s_android_path )) {
87
+ return aws_string_c_str ( s_android_path ) ;
82
88
}
83
89
84
90
/* Free BSD */
85
- if (aws_path_exists ("/usr/local/share/certs" )) {
86
- return "/usr/local/share/certs" ;
91
+ if (aws_path_exists (s_free_bsd_path )) {
92
+ return aws_string_c_str ( s_free_bsd_path ) ;
87
93
}
88
94
89
95
/* Net BSD */
90
- if (aws_path_exists ("/etc/openssl/certs" )) {
91
- return "/etc/openssl/certs" ;
96
+ if (aws_path_exists (s_net_bsd_path )) {
97
+ return aws_string_c_str ( s_net_bsd_path ) ;
92
98
}
93
99
94
100
return NULL ;
95
101
}
96
102
103
+ AWS_STATIC_STRING_FROM_LITERAL (s_debian_ca_file_path , "/etc/ssl/certs/ca-certificates.crt" );
104
+ AWS_STATIC_STRING_FROM_LITERAL (s_old_rhel_ca_file_path , "/etc/pki/tls/certs/ca-bundle.crt" );
105
+ AWS_STATIC_STRING_FROM_LITERAL (s_open_suse_ca_file_path , "/etc/ssl/ca-bundle.pem" );
106
+ AWS_STATIC_STRING_FROM_LITERAL (s_open_elec_ca_file_path , "/etc/pki/tls/cacert.pem" );
107
+ AWS_STATIC_STRING_FROM_LITERAL (s_modern_rhel_ca_file_path , "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" );
108
+
97
109
static const char * s_determine_default_pki_ca_file (void ) {
98
110
/* debian variants */
99
- if (aws_path_exists ("/etc/ssl/certs/ca-certificates.crt" )) {
100
- return "/etc/ssl/certs/ca-certificates.crt" ;
111
+ if (aws_path_exists (s_debian_ca_file_path )) {
112
+ return aws_string_c_str ( s_debian_ca_file_path ) ;
101
113
}
102
114
103
115
/* Old RHEL variants */
104
- if (aws_path_exists ("/etc/pki/tls/certs/ca-bundle.crt" )) {
105
- return "/etc/pki/tls/certs/ca-bundle.crt" ;
116
+ if (aws_path_exists (s_old_rhel_ca_file_path )) {
117
+ return aws_string_c_str ( s_old_rhel_ca_file_path ) ;
106
118
}
107
119
108
120
/* Open SUSE */
109
- if (aws_path_exists ("/etc/ssl/ca-bundle.pem" )) {
110
- return "/etc/ssl/ca-bundle.pem" ;
121
+ if (aws_path_exists (s_open_suse_ca_file_path )) {
122
+ return aws_string_c_str ( s_open_suse_ca_file_path ) ;
111
123
}
112
124
113
125
/* Open ELEC */
114
- if (aws_path_exists ("/etc/pki/tls/cacert.pem" )) {
115
- return "/etc/pki/tls/cacert.pem" ;
126
+ if (aws_path_exists (s_open_elec_ca_file_path )) {
127
+ return aws_string_c_str ( s_open_elec_ca_file_path ) ;
116
128
}
117
129
118
130
/* Modern RHEL variants */
119
- if (aws_path_exists ("/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" )) {
120
- return "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" ;
131
+ if (aws_path_exists (s_modern_rhel_ca_file_path )) {
132
+ return aws_string_c_str ( s_modern_rhel_ca_file_path ) ;
121
133
}
122
134
123
135
return NULL ;
0 commit comments