Browse Source

device, device-proxy: separate certificate and certificate_pem properties

bboozzoo/self-announce
Maciek Borzecki 7 years ago
parent
commit
a7c0bc448c
2 changed files with 13 additions and 15 deletions
  1. +1
    -1
      src/mconnect/device-proxy.vala
  2. +12
    -14
      src/mconnect/device.vala

+ 1
- 1
src/mconnect/device-proxy.vala View File

@ -76,7 +76,7 @@ class DeviceDBusProxy : Object {
}
public string certificate {
get { return device.certificate; }
owned get { return device.certificate_pem; }
private set {}
}


+ 12
- 14
src/mconnect/device.vala View File

@ -69,7 +69,15 @@ class Device : Object {
}
private HashSet<string> _capabilities = null;
public string certificate { get; private set; default = ""; }
public TlsCertificate certificate = null;
public string certificate_pem { owned get {
if (this.certificate == null) {
return "";
}
return this.certificate.certificate_pem;
}
private set {}
}
public string certificate_fingerprint { get; private set; default = ""; }
// set to true if pair request was sent
@ -206,7 +214,7 @@ class Device : Object {
cache.set_string(name, "lastIPAddress", this.host.to_string());
cache.set_boolean(name, "allowed", this.allowed);
cache.set_boolean(name, "paired", this.is_paired);
cache.set_string(name, "certificate", this.certificate);
cache.set_string(name, "certificate", this.certificate_pem);
cache.set_string_list(name, "outgoing_capabilities",
this.outgoing_capabilities.to_array());
cache.set_string_list(name, "incoming_capabilities",
@ -222,18 +230,8 @@ class Device : Object {
core.handlers.interfaces,
core.handlers.interfaces));
TlsCertificate? expected_cert = null;
if (this.certificate != "") {
try {
expected_cert = new TlsCertificate.from_pem(this.certificate,
this.certificate.length);
} catch (Error e) {
warning("failed to parse cached PEM cert of device %s: %s",
this.device_id, e.message);
}
}
// switch to secure channel
var secure = yield _channel.secure(expected_cert);
var secure = yield _channel.secure(this.certificate);
info("secure: %s", secure.to_string());
if (secure) {
@ -581,7 +579,7 @@ class Device : Object {
}
private void update_certificate(TlsCertificate cert) {
this.certificate = cert.certificate_pem;
this.certificate = cert;
// prepare fingerprint
var fingerprint = Crypt.fingerprint_certificate(cert.certificate_pem);


Loading…
Cancel
Save