@@ -49,14 +49,15 @@ accept_content(ReqData0, Context) ->
49
49
Port = safe_parse_int (maps :get (port , BodyMap , 389 ), " port" ),
50
50
UseSsl = safe_parse_bool (maps :get (use_ssl , BodyMap , false ), " use_ssl" ),
51
51
UseStartTls = safe_parse_bool (maps :get (use_starttls , BodyMap , false ), " use_starttls" ),
52
- Servers = maps : get ( servers , BodyMap , [] ),
52
+ Servers = safe_parse_servers ( BodyMap ),
53
53
UserDN = maps :get (user_dn , BodyMap , <<" " >>),
54
54
Password = maps :get (password , BodyMap , <<" " >>),
55
55
Options0 = [
56
56
{port , Port },
57
57
{timeout , 5000 }
58
58
],
59
59
{ok , Options1 } = maybe_add_ssl_options (Options0 , UseSsl , BodyMap ),
60
+ ct :pal (" @@@@ SERVES: ~tp " ,[Servers ]),
60
61
case eldap :open (Servers , Options1 ) of
61
62
{ok , LDAP } ->
62
63
Result = case maybe_starttls (LDAP , UseStartTls , BodyMap ) of
@@ -178,8 +179,8 @@ tls_options(BodyMap) when is_map_key(ssl_options, BodyMap) ->
178
179
TlsOpts2 ;
179
180
Verify ->
180
181
try
181
- VerifyStr = unicode : characters_to_list (Verify ),
182
- [{verify , list_to_existing_atom (VerifyStr )} | TlsOpts2 ]
182
+ VerifyStr = to_unicode (Verify ),
183
+ [{verify , binary_to_existing_atom (VerifyStr )} | TlsOpts2 ]
183
184
catch
184
185
error :badarg ->
185
186
throw ({bad_request , " invalid verify option passed to "
@@ -211,9 +212,10 @@ tls_options(BodyMap) when is_map_key(ssl_options, BodyMap) ->
211
212
undefined ->
212
213
TlsOpts5 ;
213
214
VersionStrs when is_list (VersionStrs ) ->
214
- F1 = fun (VStr ) ->
215
+ F1 = fun (VStr0 ) ->
215
216
try
216
- {true , list_to_existing_atom (VStr )}
217
+ VStr1 = to_unicode (VStr0 ),
218
+ {true , binary_to_existing_atom (VStr1 )}
217
219
catch error :badarg ->
218
220
throw ({bad_request , " invalid TLS version passed to "
219
221
" /ldap/validate/simple-bind ssl_options.versions" })
@@ -222,10 +224,10 @@ tls_options(BodyMap) when is_map_key(ssl_options, BodyMap) ->
222
224
Versions = lists :filtermap (F1 , VersionStrs ),
223
225
[{versions , Versions } | TlsOpts5 ]
224
226
end ,
225
- TlsOpts7 = case maps :get (<<" ssl_hostname_verification" >>, SslOptionsMap , undefined ) of
227
+ TlsOpts7 = case to_unicode ( maps :get (<<" ssl_hostname_verification" >>, SslOptionsMap , undefined ) ) of
226
228
undefined ->
227
229
TlsOpts6 ;
228
- " wildcard" ->
230
+ << " wildcard" >> ->
229
231
[{customize_hostname_check , [{match_fun , public_key :pkix_verify_hostname_match_fun (https )}]} | TlsOpts6 ];
230
232
_ ->
231
233
throw ({bad_request , " invalid value passed to "
@@ -235,6 +237,9 @@ tls_options(BodyMap) when is_map_key(ssl_options, BodyMap) ->
235
237
tls_options (_BodyMap ) ->
236
238
{ok , []}.
237
239
240
+ to_unicode (Arg ) ->
241
+ rabbit_data_coercion :to_utf8_binary (Arg ).
242
+
238
243
unicode_format (Arg ) ->
239
244
rabbit_data_coercion :to_utf8_binary (io_lib :format (" ~tp " , [Arg ])).
240
245
@@ -246,6 +251,13 @@ format_password_for_logging(<<>>) ->
246
251
format_password_for_logging (Password ) ->
247
252
io_lib :format (" [~p characters]" , [string :length (Password )]).
248
253
254
+ safe_parse_servers (BodyMap ) when is_map (BodyMap ) ->
255
+ safe_parse_servers (maps :get (servers , BodyMap , []));
256
+ safe_parse_servers (Servers ) when is_list (Servers ) ->
257
+ [rabbit_data_coercion :to_unicode_charlist (S ) || S <- Servers ];
258
+ safe_parse_servers (_ ) ->
259
+ [].
260
+
249
261
safe_parse_int (Value , FieldName ) ->
250
262
try
251
263
rabbit_mgmt_util :parse_int (Value )
0 commit comments