getTransportCredentials method

  1. @override
Future<ChannelCredentials> getTransportCredentials()
override

Implementation

@override
Future<ChannelCredentials> getTransportCredentials() async {
  RawSecureSocket socket =
  await RawSecureSocket.connect(apiUrl.host, apiUrl.port);
  if (socket.peerCertificate == null) {
    throw Exception("peer certificate is null. Contact info@nuntio.io");
  }
  X509Certificate x509certificate = socket.peerCertificate!;
  return ChannelCredentials.secure(
    certificates: utf8.encode(x509certificate.pem),
    onBadCertificate: onBadCertificate,
    authority: apiUrl.host,
  );
}