TlsCertificate

constructor(file: String)

Creates a #GTlsCertificate from the data in @file.

As of 2.72, if the filename ends in .p12 or .pfx the data is loaded by g_tls_certificate_new_from_pkcs12() otherwise it is loaded by g_tls_certificate_new_from_pem(). See those functions for exact details.

If @file cannot be read or parsed, the function will return null and set @error.

Return

the new certificate, or null on error

Since

2.28

Parameters

file

file containing a certificate to import


constructor(certFile: String, keyFile: String)

Creates a #GTlsCertificate from the PEM-encoded data in @cert_file and @key_file. The returned certificate will be the first certificate found in @cert_file. As of GLib 2.44, if @cert_file contains more certificates it will try to load a certificate chain. All certificates will be verified in the order found (top-level certificate should be the last one in the file) and the #GTlsCertificate:issuer property of each certificate will be set accordingly if the verification succeeds. If any certificate in the chain cannot be verified, the first certificate in the file will still be returned.

If either file cannot be read or parsed, the function will return null and set @error. Otherwise, this behaves like g_tls_certificate_new_from_pem().

Return

the new certificate, or null on error

Since

2.28

Parameters

certFile

file containing one or more PEM-encoded certificates to import

keyFile

file containing a PEM-encoded private key to import


constructor(data: String, length: Long)

Creates a #GTlsCertificate from the PEM-encoded data in @data. If

Return

the new certificate, or null if @data is invalid

Since

2.28

Parameters

data

PEM-encoded certificate data

length

the length of @data, or -1 if it's 0-terminated.


constructor(pkcs11Uri: String, privateKeyPkcs11Uri: String? = null)

Creates a #GTlsCertificate from a PKCS \#11 URI.

An example @pkcs11_uri would be pkcs11:model=Model;manufacturer=Manufacture;serial=1;token=My%20Client%20Certificate;id=%01

Where the token’s layout is:

|[ Object 0: URL: pkcs11:model=Model;manufacturer=Manufacture;serial=1;token=My%20Client%20Certificate;id=%01;object=private%20key;type=private Type: Private key (RSA-2048) ID: 01

Object 1: URL: pkcs11:model=Model;manufacturer=Manufacture;serial=1;token=My%20Client%20Certificate;id=%01;object=Certificate%20for%20Authentication;type=cert Type: X.509 Certificate (RSA-2048) ID: 01 ]|

In this case the certificate and private key would both be detected and used as expected.

Return

the new certificate, or null on error

Since

2.68

Parameters

pkcs11Uri

A PKCS \#11 URI

privateKeyPkcs11Uri

A PKCS \#11 URI


constructor(pointer: <Error class: unknown class><<Error class: unknown class>>)