+ if ((ret = mbedtls_md(md_info, peer_cert->raw.p, peer_cert->raw.len, hash)) != 0)
+ {
+ rb_lib_log("rb_get_ssl_certfp: unable to get certfp for F: %p, -0x%x", -ret);
+ hashlen = 0;
+ }
+ }
+ else
+ {
+ const size_t der_pubkey_bufsz = 4096;
+ void *der_pubkey = rb_malloc(der_pubkey_bufsz);
+ int der_pubkey_len;
+
+ der_pubkey_len = mbedtls_pk_write_pubkey_der((mbedtls_pk_context *)&peer_cert->pk, der_pubkey, der_pubkey_bufsz);
+ if (der_pubkey_len < 0)
+ {
+ rb_lib_log("rb_get_ssl_certfp: unable to get pubkey for F: %p, -0x%x", -der_pubkey_len);
+ hashlen = 0;
+ }
+ else if ((ret = mbedtls_md(md_info, der_pubkey+(der_pubkey_bufsz-der_pubkey_len), der_pubkey_len, hash)) != 0)
+ {
+ rb_lib_log("rb_get_ssl_certfp: unable to get certfp for F: %p, -0x%x", -ret);
+ hashlen = 0;
+ }
+
+ rb_free(der_pubkey);