Cert
Object Hierarchy:
Description:
public class Cert : Object
The key and certificate files one program uses for HTTPS RPC.
Used by both ends: ollmfilesd makes the server's files, ollmapp makes the client's. Configure with construct properties, then call
ensure once: it creates the files if needed and sets
certificate (this program's own) and
trust (the product CA the other end must be signed by). When
ca_pem_path and
ca_key_path are set the certificate is signed with that CA;
otherwise it is self-signed.
ensure does not throw. Files that are missing or will not load are
recreated; anything else (directory not creatable, CA files missing, cannot write) is a broken install and aborts with
GLib.error.
Example
// server (ollmfilesd)
var server = new OLLMrpc.Transport.Cert() {
dir = tls_dir,
ca_pem_path = ca_pem,
ca_key_path = ca_key,
server_san = true,
};
server.ensure();
http.tls_certificate = server.certificate;
// device client (ollmapp)
var client = new OLLMrpc.Transport.Cert() {
dir = GLib.Path.build_filename(
GLib.Environment.get_user_data_dir(), "ollmchat"),
cert_pem = "client.pem",
key_pem = "client-key.pem",
cn = "ollmchat-device",
};
client.ensure();
var http = new OLLMrpc.Transport.HttpClient(url) {
bin_body = true,
tls_certificate = client.certificate,
tls_database = client.trust
};
Content:
Properties:
- public string ca_key_path { get; set; }
Product CA private key file (ollmfilesd only).
- public string ca_pem_path { get; set; }
Product CA certificate file used to sign our certificate. Empty (with
empty ca_key_path) means self-signed.
- public string cert_pem { get; set; }
Certificate file name under
dir.
- public TlsCertificate certificate { get; }
This program's own certificate and key, set by
ensure.
- public string cn { get; set; }
Name written into the certificate (X.509 common name).
- public string dir { get; set; }
Directory the key, certificate and trust files live in.
- public string key_pem { get; set; }
Private key file name under
dir.
- public bool server_san { get; set; }
Server only: also make the certificate valid for localhost.
- public TlsDatabase? trust { get; }
- public string trust_pem { get; set; }
Trust PEM basename under
dir when
ca_pem_path is empty. Default ollmrpc-ca.pem.
Creation methods:
Methods:
- public void ensure ()
Make sure this program's key and certificate files exist under
dir, then set
certificate and
trust from them.
- public void remove ()
Delete the key, certificate, CSR, and trust file under
dir.
Inherited Members:
All known members inherited from class GLib.Object
- @get
- @new
- @ref
- @set
- add_toggle_ref
- add_weak_pointer
- bind_property
- connect
- constructed
- disconnect
- dispose
- dup_data
- dup_qdata
- force_floating
- freeze_notify
- get_class
- get_data
- get_property
- get_qdata
- get_type
- getv
- interface_find_property
- interface_install_property
- interface_list_properties
- is_floating
- new_valist
- new_with_properties
- newv
- notify
- notify_property
- ref_count
- ref_sink
- remove_toggle_ref
- remove_weak_pointer
- replace_data
- replace_qdata
- set_data
- set_data_full
- set_property
- set_qdata
- set_qdata_full
- set_valist
- setv
- steal_data
- steal_qdata
- thaw_notify
- unref
- watch_closure
- weak_ref
- weak_unref