loadBase64 method

void loadBase64(
  1. String keyStr
)

Loads a public key from standard Base64-encoded DER in keyStr. Whitespace within the Base64 text is permitted. The decoded DER is inspected to determine the key type and structure. For RSA, both PKCS #1 RSAPublicKey and X.509 SubjectPublicKeyInfo are recognized.

A complete PEM string is also accepted, including its BEGIN/END boundary lines. Base64url text, arbitrary non-PEM text surrounding the encoded data, X.509 certificates, and encrypted private keys are not accepted.

A successful load replaces the current key. A failed load clears this object.

Certificates and encrypted private keys: Direct X.509 certificate input is not supported. Load a certificate with a Cert object and obtain its public key from the certificate. Encrypted private-key input is also not supported by this class; load and decrypt it with a PrivateKey object, then obtain the corresponding public key.

DER terminology: The general X.509 public-key wrapper is SubjectPublicKeyInfo. It is sometimes informally called a “PKCS #8 public key,” although PKCS #8 formally defines private-key syntax.

Throws a ChilkatException if the call fails; the details are in ChilkatException.lastErrorText. Throws an ArgumentError if a string argument contains a NUL character.

Implementation

void loadBase64(String keyStr) {
  final h = _handle;
  using((arena) {
    final r = _CkPublicKey_LoadBase64(h, _toNative(arena, keyStr, 'keyStr'));
    if (r == 0) {
      throw _fail('loadBase64');
    }
  });
}