Skip to content

TLS Connection  #189

Closed
Closed
@ManuelLatorre98

Description

@ManuelLatorre98

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions