Please proivde a function gnutls_x509_crt_key_encrypt() which uses the subjectPublicKey to encrypt the given data. gnutls_x509_crt_key_encrypt(gnutls_x509_crt_t cert, const void * ptext, size_t ptext_len, void * ctext, size_t ctext_len); or a way to extract the public key so you can do it with the public key API. This is needed to implement the MS-BRKP protocol in Samba with GnuTLS.
It is the other way around. Looks like gnutls_pubkey_import_x509() imports the sPKI of the cert. However encryption fails doesn't work, need to check why ...