Browse Source

crypt: take string instead of uint8[] as PEM encoded certificate

bboozzoo/tls-support
Maciek Borzecki 7 years ago
parent
commit
3f3abe76cb
2 changed files with 5 additions and 5 deletions
  1. +4
    -4
      src/crypt/certificate.vala
  2. +1
    -1
      test/mconn-crypt-vala-test.vala

+ 4
- 4
src/crypt/certificate.vala View File

@ -147,9 +147,9 @@ namespace Mconn {
export_to_file(key_path, export_private_key(key));
}
private GnuTLS.X509.Certificate cert_from_pem(uint8[] certificate_pem) {
var datum = GnuTLS.Datum() { data=certificate_pem,
size=certificate_pem.length };
private GnuTLS.X509.Certificate cert_from_pem(string certificate_pem) {
var datum = GnuTLS.Datum() { data=certificate_pem.data,
size=certificate_pem.data.length };
var cert = GnuTLS.X509.Certificate.create();
var res = cert.import(ref datum, GnuTLS.X509.CertificateFormat.PEM);
@ -164,7 +164,7 @@ namespace Mconn {
* @param certificate_pem PEM encoded certificate
* @return SHA1 fingerprint as bytes
*/
public uint8[] fingerprint_certificate(uint8[] certificate_pem) {
public uint8[] fingerprint_certificate(string certificate_pem) {
var cert = cert_from_pem(certificate_pem);
// TOOD: make digest configurable, for now assume it's SHA1


+ 1
- 1
test/mconn-crypt-vala-test.vala View File

@ -107,7 +107,7 @@ sCmsSGcb9ZkEQfRNGTmFFthkcnfTU9mKh8oGc/a9r0DDgYcPSCgqERt2fgiBrt85
-----END CERTIFICATE-----""";
var expected = "eb2611a447085322b206fa61d4bc5869b4a55657";
var fingerprint = Crypt.fingerprint_certificate(pem.data);
var fingerprint = Crypt.fingerprint_certificate(pem);
// SHA1
assert(fingerprint.length == 20);


Loading…
Cancel
Save