Dart
Dart
ZATCA Load Certificate and Private Key from PEM Files
See more ZATCA Examples
Demonstrates how to load a certificate and private key from a pair of PEM files.Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
// The LoadFromFile method will automatically detect the file format..
final cert = CkCert();
try {
cert.loadFromFile('qa_data/zatca/cert.pem');
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
print(cert.subjectCN);
// Load the private key.
final privKey = CkPrivateKey();
try {
privKey.loadPemFile('qa_data/zatca/ec-secp256k1-priv-key.pem');
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
print('Key Type: ${privKey.keyType}');
// Associate the private key with the certificate.
try {
cert.setPrivateKey(privKey);
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
print('Success.');
}