Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TLS Connection #189

Closed
ManuelLatorre98 opened this issue May 3, 2024 · 1 comment
Closed

TLS Connection #189

ManuelLatorre98 opened this issue May 3, 2024 · 1 comment

Comments

@ManuelLatorre98
Copy link

ManuelLatorre98 commented May 3, 2024

Hello I'm trying to make a TLS connection between my device and a remote server. I making this to stablish the connection:

 const options ={
      port:3001,
      host:ipLider,
      localAddress:'0.0.0.0',
      reuseAddress:true,
      ca:require('../../../android/app/src/main/assets/certificates/pub.pem')
    }
    return new Promise((resolve, reject) => {
      const socket = TcpSocket.connectTLS(options,()=>{});
      socket.on('error', (error: Error) => {
        reject("Connection Error:" + error);
      });
      

And have metro.config.js configured like this to be able to use pem and .p12 files:

const {getDefaultConfig} = require('metro-config');
const defaultConfig = getDefaultConfig.getDefaultValues(__dirname);
module.exports = {
  resolver: {
    assetExts: [...defaultConfig.resolver.assetExts, 'pem', 'p12'],
  },
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: true,
      },
    }),
  },
};

I'm working with Typescript and when i try stablish connection I get the follow error:

Internal server error: Connection Error:com.android.org.conscrypt.OpenSSLX509CertificateFactory$ParsingException: com.android.org.conscrypt.OpenSSLX509CertificateFactory$ParsingException: java.lang.RuntimeException: error:0900006e:PEM routines:OPENSSL_internal:NO_START_LINE

(if i use import instead of require the app crashes)

I maked the public and private keys with ecc 25519 this is the text in pub.pem file of the public key:

-----BEGIN PUBLIC KEY-----
MCowBQYDK2VwAyEAVBEuY4MD7DMajUYgyav7n9s/99STNRuYMtAwgFHdLpE=
-----END PUBLIC KEY-----

Any idea of what im doing wrong?

@vricosti
Copy link
Contributor

in ca you are passing the public key, it should be a certificate...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants