Rapsssito / react-native-tcp-socket

React Native TCP socket API for Android, iOS & macOS with SSL/TLS support.
MIT License
316 stars 81 forks source link

Android CertPathValidatorException when sending TLS True #139

Closed techie-gabbar closed 2 years ago

techie-gabbar commented 2 years ago
 var options = {
              port: 6467,
              host: host,
              tls: true,
              tlsCheckValidity: false,
              tlsCert: require('./public-cert.pem')
         }

            const client = TcpSocket.createConnection(options, () => {
              console.log("Connccted");
            });

When sending above thing in Android. Than Below Error is coming. Can u please help. The public-cert.pem is in my root react native project.

ERROR: "java.security.cert.CertPathValidatorException: Trust anchor for certification path not found."

@Rapsssito @joshuamiller @eddieAnthem Please Help

Rapsssito commented 2 years ago

@techie-gabbar, make sure you follow the docs and add the file to the metro.config.js file.

techie-gabbar commented 2 years ago

@Rapsssito I followed the docs and this below is mine metro.config.js file

const { getDefaultConfig } = require('metro-config');
const defaultConfig = getDefaultConfig.getDefaultValues(__dirname);

module.exports = {
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: true,
      },
    }),
  },
  resolver: {
    assetExts: [...defaultConfig.resolver.assetExts, 'pem'],
  }
};

@Rapsssito Is there anything wrong i am doing. Can u help m what i am doing wrong.

  var options = {
              port: 6467,
              host: host,
              tls: true,
              // tlsCheckValidity: false,
              // tlsCert: require('./client.pem'),
              //tlsCert: require('./public-cert.pem')
}
techie-gabbar commented 2 years ago

@Rapsssito I followed the docs and this below is mine metro.config.js file

const { getDefaultConfig } = require('metro-config');
const defaultConfig = getDefaultConfig.getDefaultValues(__dirname);

module.exports = {
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: true,
      },
    }),
  },
  resolver: {
    assetExts: [...defaultConfig.resolver.assetExts, 'pem'],
  }
};

@Rapsssito Is there anything wrong i am doing. Can u help m what i am doing wrong.

  var options = {
              port: 6467,
              host: host,
              tls: true,
              // tlsCheckValidity: false,
              // tlsCert: require('./client.pem'),
              //tlsCert: require('./public-cert.pem')
}

@Rapsssito Can u please help in above. It would be great help.

Rapsssito commented 2 years ago

@techie-gabbar could you post the full error stack trace? Also, you should check this stackoverflow question.

github-actions[bot] commented 2 years ago

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community attention? This issue may be closed if no further activity occurs.