Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48983

Advanced-http plugin error. TLS connection could not be established: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException

$
0
0

Good day. Could anybody suggest please how to solve this problem?

TLS connection could not be established: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found

I use…

Ionic:

   Ionic CLI                     : 5.4.16
   Ionic Framework               : @ionic/angular 5.1.1
   @angular-devkit/build-angular : 0.803.10
   @angular-devkit/schematics    : 8.3.10
   @angular/cli                  : 8.3.10
   @ionic/angular-toolkit        : 2.0.0

Cordova:

   Cordova CLI       : 10.0.0
   Cordova Platforms : android 9.0.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.1.3, (and 26 other plugins)

Utility:

   cordova-res : not installed
   native-run  : not installed

System:

   Android SDK Tools : 26.1.1 (C:\Users\anton\AppData\Local\Android\Sdk)
   NodeJS            : v12.15.0 (C:\Program Files\nodejs\node.exe)
   npm               : 6.13.4
   OS                : Windows 10

I add to config.xml

<preference name="AndroidBlacklistSecureSocketProtocols" value="SSLv3,TLSv1" />

My function:

 post(link, data): Promise<any> {
    return new Promise((resolve, reject) => {
      if (this.isOnline()) {

        data = Object.assign(data, {rnd: new Date().getTime()});

        if (this.debug_mode) {
          console.log("datadata", data);
        }

        let params = " params: ";
        for (let field in data) {
          if (field == "p") {
            params += " p:*****"
          }
          else
            params += " " + field + ":" + data[field];
        }

        if (this.debug_mode) {
          console.log('data_params', data);
          console.log("params", params);
        }

        this.logProvider.writeLog("RETRIEVE: start post on link " + link + " " + params);

        this.http.sendRequest(link,
            {
              method: 'post',
              data: data,
              timeout: 30000
            }
        ).then(result => {

          // prints 200
          console.log(result.status);


          try {
            result.data = JSON.parse(result.data);
            // prints test
            console.log(result.data.message);
          } catch (e) {
            console.error('JSON parsing error');
          }

          this.logProvider.writeLog("RETRIEVE: finish post on link " + link);

          if (this.debug_mode) {
            console.log("result.data", result.data);
          }

          //console.log("result", result);
          resolve(result.data);

          // prints 200
          console.log(result.status);
        }).catch(err => {

          // A client-side or network error occurred. Handle it accordingly.

          if (this.debug_mode) {
            console.log('An error occurred post:', err);
          }

          this.logProvider.writeLog("ERROR: error in answer from server " + err.error + " status " + err.status + " link " + link + params);

          reject(err.error);

          // prints 403
          console.log(err.status);

          // prints Permission denied
          console.log(err.error);
        });


     
      } else {
        this.logProvider.writeLog("going to post on link " + link + " but device is offline");
        reject({text: "device is offline"});
      }

    });
  }

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 48983

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>