Dart
Dart
Load Certificate from .cer and Private Key from .pem
See more Certificates Examples
Load a certificate from a .cer and its associated private key from a .pem.Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
final cert = CkCert();
try {
cert.loadFromFile('C:/certs_and_keys/Certificate.cer');
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
final sbPem = CkStringBuilder();
try {
sbPem.loadFile('C:/certs_and_keys/PrivateKey.pem', 'utf-8');
} on ChilkatException {
print('Failed to load private key PEM');
return;
}
try {
cert.setPrivateKeyPem(sbPem.getAsString());
} on ChilkatException catch (e) {
print(e.lastErrorText);
return;
}
print('The certificate and associated private key are now loaded and ready for signing.');
}