Sample code for 30+ languages & platforms
Dart Requires Chilkat v11.0.0+

Get Public Key from Certificate PEM

See more Certificates Examples

Loads a certificate from a PEM file and gets the cert's public key.

Chilkat Dart Downloads

Dart
import 'package:chilkat/chilkat.dart';

void main() {
  final cert = CkCert();

  try {
    cert.loadFromFile('qa_data/certs/someCert.pem');
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  // Get the certificate's public key:
  final pubkey = CkPublicKey();
  cert.getPublicKey(pubkey);

  print(pubkey.getPem(false));

  // OK.. we have the public key which can be used in other Chilkat classes/methods...
}