@@ -25,11 +25,12 @@ class SIPUAWebSocketImpl {
2525 handleQueue ();
2626 logger.i ('connect $_url , ${webSocketSettings .extraHeaders }, $protocols ' );
2727 try {
28- if (webSocketSettings.allowBadCertificate || webSocketSettings.debugCertificate) {
28+ if (webSocketSettings.allowBadCertificate ||
29+ webSocketSettings.debugCertificate) {
2930 // Depending on the settings, it will allow self-signed certificates or debug them.
30- _socket = await _connectWithBadCertificateHandling (_url, webSocketSettings);
31- }
32- else {
31+ _socket =
32+ await _connectWithBadCertificateHandling (_url, webSocketSettings);
33+ } else {
3334 _socket = await WebSocket .connect (_url,
3435 protocols: protocols, headers: webSocketSettings.extraHeaders);
3536 }
@@ -84,23 +85,22 @@ class SIPUAWebSocketImpl {
8485
8586 client.badCertificateCallback =
8687 (X509Certificate cert, String host, int port) {
87- if (webSocketSettings.allowBadCertificate) {
88+ if (webSocketSettings.allowBadCertificate) {
8889 logger.w ('Allow self-signed certificate => $host :$port . ' );
8990 return true ;
90- }
91- else if (webSocketSettings.debugCertificate){
92- logger. w ( 'Server returns a server certificate that cannot be authenticated => $host :$port . ' );
91+ } else if (webSocketSettings.debugCertificate) {
92+ logger. w (
93+ 'Server returns a server certificate that cannot be authenticated => $host :$port . ' );
9394 String certInfo = '\n ' ;
94- certInfo+= ' Certificate subject: ${cert .subject }\n ' ;
95- certInfo+= ' Certificate issuer: ${cert .issuer }\n ' ;
96- certInfo+= ' Certificate valid from: ${cert .startValidity }\n ' ;
97- certInfo+= ' Certificate valid to: ${cert .endValidity }\n ' ;
98- certInfo+= ' Certificate SHA-1 fingerprint: ${cert .sha1 }\n ' ;
95+ certInfo += ' Certificate subject: ${cert .subject }\n ' ;
96+ certInfo += ' Certificate issuer: ${cert .issuer }\n ' ;
97+ certInfo += ' Certificate valid from: ${cert .startValidity }\n ' ;
98+ certInfo += ' Certificate valid to: ${cert .endValidity }\n ' ;
99+ certInfo += ' Certificate SHA-1 fingerprint: ${cert .sha1 }\n ' ;
99100
100101 logger.w ('Certificate details: {$certInfo }' );
101102 return false ;
102- }
103- else {
103+ } else {
104104 return false ; // reject the certificate
105105 }
106106 };
0 commit comments