qcrypto_tls_creds_x509_load(QCryptoTLSCredsX509 *creds,
                            Error **errp)
{
    char *cacert = NULL, *cacrl = NULL, *cert = NULL,
        *key = NULL, *dhparams = NULL;
    int ret;
    int rv = -1;
    trace_qcrypto_tls_creds_x509_load(creds,
            creds->parent_obj.dir ? creds->parent_obj.dir : "<nodir>");
    if (creds->parent_obj.endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) {
        if (qcrypto_tls_creds_get_path(&creds->parent_obj,
                                       QCRYPTO_TLS_CREDS_X509_CA_CERT,
                                       true, &cacert, errp) < 0 ||
            qcrypto_tls_creds_get_path(&creds->parent_obj,
                                       QCRYPTO_TLS_CREDS_X509_CA_CRL,
                                       false, &cacrl, errp) < 0 ||
            qcrypto_tls_creds_get_path(&creds->parent_obj,
                                       QCRYPTO_TLS_CREDS_X509_SERVER_CERT,
                                       true, &cert, errp) < 0 ||
            qcrypto_tls_creds_get_path(&creds->parent_obj,
                                       QCRYPTO_TLS_CREDS_X509_SERVER_KEY,
                                       true, &key, errp) < 0 ||
            qcrypto_tls_creds_get_path(&creds->parent_obj,
                                       QCRYPTO_TLS_CREDS_DH_PARAMS,
                                       false, &dhparams, errp) < 0) {
    } else {
        if (qcrypto_tls_creds_get_path(&creds->parent_obj,
                                       QCRYPTO_TLS_CREDS_X509_CA_CERT,
                                       true, &cacert, errp) < 0 ||
            qcrypto_tls_creds_get_path(&creds->parent_obj,
                                       QCRYPTO_TLS_CREDS_X509_CLIENT_CERT,
                                       false, &cert, errp) < 0 ||
            qcrypto_tls_creds_get_path(&creds->parent_obj,
                                       QCRYPTO_TLS_CREDS_X509_CLIENT_KEY,
                                       false, &key, errp) < 0) {
    ret = gnutls_certificate_allocate_credentials(&creds->data);
    if (ret < 0) {
        error_setg(errp, "Cannot allocate credentials: '%s'",
                   gnutls_strerror(ret));
    ret = gnutls_certificate_set_x509_trust_file(creds->data,
                                                 cacert,
                                                 GNUTLS_X509_FMT_PEM);
    if (ret < 0) {
        error_setg(errp, "Cannot load CA certificate '%s': %s",
                   cacert, gnutls_strerror(ret));
    if (cert != NULL && key != NULL) {
        ret = gnutls_certificate_set_x509_key_file(creds->data,
                                                   cert, key,
                                                   GNUTLS_X509_FMT_PEM);
        if (ret < 0) {
            error_setg(errp, "Cannot load certificate '%s' & key '%s': %s",
                       cert, key, gnutls_strerror(ret));
    if (cacrl != NULL) {
        ret = gnutls_certificate_set_x509_crl_file(creds->data,
                                                   cacrl,
                                                   GNUTLS_X509_FMT_PEM);
        if (ret < 0) {
            error_setg(errp, "Cannot load CRL '%s': %s",
                       cacrl, gnutls_strerror(ret));
    if (creds->parent_obj.endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) {
        if (qcrypto_tls_creds_get_dh_params_file(&creds->parent_obj, dhparams,
                                                 &creds->parent_obj.dh_params,
                                                 errp) < 0) {
        gnutls_certificate_set_dh_params(creds->data,
                                         creds->parent_obj.dh_params);
    rv = 0;
 cleanup:
    g_free(cacert);
    g_free(cacrl);
    g_free(cert);
    g_free(key);
    g_free(dhparams);
    return rv;
qcrypto_tls_creds_x509_load(QCryptoTLSCredsX509 *creds,
                            Error **errp)
{
    char *cacert = NULL, *cacrl = NULL, *cert = NULL,
        *key = NULL, *dhparams = NULL;
    int ret;
    int rv = -1;
    trace_qcrypto_tls_creds_x509_load(creds,
            creds->parent_obj.dir ? creds->parent_obj.dir : "<nodir>");
    if (creds->parent_obj.endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) {
        if (qcrypto_tls_creds_get_path(&creds->parent_obj,
                                       QCRYPTO_TLS_CREDS_X509_CA_CERT,
                                       true, &cacert, errp) < 0 ||
            qcrypto_tls_creds_get_path(&creds->parent_obj,
                                       QCRYPTO_TLS_CREDS_X509_CA_CRL,
                                       false, &cacrl, errp) < 0 ||
            qcrypto_tls_creds_get_path(&creds->parent_obj,
                                       QCRYPTO_TLS_CREDS_X509_SERVER_CERT,
                                       true, &cert, errp) < 0 ||
            qcrypto_tls_creds_get_path(&creds->parent_obj,
                                       QCRYPTO_TLS_CREDS_X509_SERVER_KEY,
                                       true, &key, errp) < 0 ||
            qcrypto_tls_creds_get_path(&creds->parent_obj,
                                       QCRYPTO_TLS_CREDS_DH_PARAMS,
                                       false, &dhparams, errp) < 0) {
    } else {
        if (qcrypto_tls_creds_get_path(&creds->parent_obj,
                                       QCRYPTO_TLS_CREDS_X509_CA_CERT,
                                       true, &cacert, errp) < 0 ||
            qcrypto_tls_creds_get_path(&creds->parent_obj,
                                       QCRYPTO_TLS_CREDS_X509_CLIENT_CERT,
                                       false, &cert, errp) < 0 ||
            qcrypto_tls_creds_get_path(&creds->parent_obj,
                                       QCRYPTO_TLS_CREDS_X509_CLIENT_KEY,
                                       false, &key, errp) < 0) {
    ret = gnutls_certificate_allocate_credentials(&creds->data);
    if (ret < 0) {
        error_setg(errp, "Cannot allocate credentials: '%s'",
                   gnutls_strerror(ret));
    ret = gnutls_certificate_set_x509_trust_file(creds->data,
                                                 cacert,
                                                 GNUTLS_X509_FMT_PEM);
    if (ret < 0) {
        error_setg(errp, "Cannot load CA certificate '%s': %s",
                   cacert, gnutls_strerror(ret));
    if (cert != NULL && key != NULL) {
        ret = gnutls_certificate_set_x509_key_file(creds->data,
                                                   cert, key,
                                                   GNUTLS_X509_FMT_PEM);
        if (ret < 0) {
            error_setg(errp, "Cannot load certificate '%s' & key '%s': %s",
                       cert, key, gnutls_strerror(ret));
    if (cacrl != NULL) {
        ret = gnutls_certificate_set_x509_crl_file(creds->data,
                                                   cacrl,
                                                   GNUTLS_X509_FMT_PEM);
        if (ret < 0) {
            error_setg(errp, "Cannot load CRL '%s': %s",
                       cacrl, gnutls_strerror(ret));
    if (creds->parent_obj.endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) {
        if (qcrypto_tls_creds_get_dh_params_file(&creds->parent_obj, dhparams,
                                                 &creds->parent_obj.dh_params,
                                                 errp) < 0) {
        gnutls_certificate_set_dh_params(creds->data,
                                         creds->parent_obj.dh_params);
    rv = 0;
 cleanup:
    g_free(cacert);
    g_free(cacrl);
    g_free(cert);
    g_free(key);
    g_free(dhparams);
    return rv;
FUNC_0(QCryptoTLSCredsX509 *VAR_0,
                            Error **VAR_1)
{
    char *VAR_2 = NULL, *VAR_3 = NULL, *VAR_4 = NULL,
        *VAR_5 = NULL, *VAR_6 = NULL;
    int VAR_7;
    int VAR_8 = -1;
    trace_qcrypto_tls_creds_x509_load(VAR_0,
            VAR_0->parent_obj.dir ? VAR_0->parent_obj.dir : "<nodir>");
    if (VAR_0->parent_obj.endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) {
        if (qcrypto_tls_creds_get_path(&VAR_0->parent_obj,
                                       QCRYPTO_TLS_CREDS_X509_CA_CERT,
                                       true, &VAR_2, VAR_1) < 0 ||
            qcrypto_tls_creds_get_path(&VAR_0->parent_obj,
                                       QCRYPTO_TLS_CREDS_X509_CA_CRL,
                                       false, &VAR_3, VAR_1) < 0 ||
            qcrypto_tls_creds_get_path(&VAR_0->parent_obj,
                                       QCRYPTO_TLS_CREDS_X509_SERVER_CERT,
                                       true, &VAR_4, VAR_1) < 0 ||
            qcrypto_tls_creds_get_path(&VAR_0->parent_obj,
                                       QCRYPTO_TLS_CREDS_X509_SERVER_KEY,
                                       true, &VAR_5, VAR_1) < 0 ||
            qcrypto_tls_creds_get_path(&VAR_0->parent_obj,
                                       QCRYPTO_TLS_CREDS_DH_PARAMS,
                                       false, &VAR_6, VAR_1) < 0) {
    } else {
        if (qcrypto_tls_creds_get_path(&VAR_0->parent_obj,
                                       QCRYPTO_TLS_CREDS_X509_CA_CERT,
                                       true, &VAR_2, VAR_1) < 0 ||
            qcrypto_tls_creds_get_path(&VAR_0->parent_obj,
                                       QCRYPTO_TLS_CREDS_X509_CLIENT_CERT,
                                       false, &VAR_4, VAR_1) < 0 ||
            qcrypto_tls_creds_get_path(&VAR_0->parent_obj,
                                       QCRYPTO_TLS_CREDS_X509_CLIENT_KEY,
                                       false, &VAR_5, VAR_1) < 0) {
    VAR_7 = gnutls_certificate_allocate_credentials(&VAR_0->data);
    if (VAR_7 < 0) {
        error_setg(VAR_1, "Cannot allocate credentials: '%s'",
                   gnutls_strerror(VAR_7));
    VAR_7 = gnutls_certificate_set_x509_trust_file(VAR_0->data,
                                                 VAR_2,
                                                 GNUTLS_X509_FMT_PEM);
    if (VAR_7 < 0) {
        error_setg(VAR_1, "Cannot load CA certificate '%s': %s",
                   VAR_2, gnutls_strerror(VAR_7));
    if (VAR_4 != NULL && VAR_5 != NULL) {
        VAR_7 = gnutls_certificate_set_x509_key_file(VAR_0->data,
                                                   VAR_4, VAR_5,
                                                   GNUTLS_X509_FMT_PEM);
        if (VAR_7 < 0) {
            error_setg(VAR_1, "Cannot load certificate '%s' & VAR_5 '%s': %s",
                       VAR_4, VAR_5, gnutls_strerror(VAR_7));
    if (VAR_3 != NULL) {
        VAR_7 = gnutls_certificate_set_x509_crl_file(VAR_0->data,
                                                   VAR_3,
                                                   GNUTLS_X509_FMT_PEM);
        if (VAR_7 < 0) {
            error_setg(VAR_1, "Cannot load CRL '%s': %s",
                       VAR_3, gnutls_strerror(VAR_7));
    if (VAR_0->parent_obj.endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) {
        if (qcrypto_tls_creds_get_dh_params_file(&VAR_0->parent_obj, VAR_6,
                                                 &VAR_0->parent_obj.dh_params,
                                                 VAR_1) < 0) {
        gnutls_certificate_set_dh_params(VAR_0->data,
                                         VAR_0->parent_obj.dh_params);
    VAR_8 = 0;
 cleanup:
    g_free(VAR_2);
    g_free(VAR_3);
    g_free(VAR_4);
    g_free(VAR_5);
    g_free(VAR_6);
    return VAR_8;
FUNC_0(QCryptoTLSCredsX509 *VAR_0,
Error **VAR_1)
{ char *VAR_2 = NULL, *VAR_3 = NULL, *VAR_4 = NULL,
*VAR_5 = NULL, *VAR_6 = NULL; int VAR_7; int VAR_8 = -1; trace_qcrypto_tls_creds_x509_load(VAR_0,
VAR_0->parent_obj.dir ? VAR_0->parent_obj.dir : "<nodir>"); if (VAR_0->parent_obj.endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) { if (qcrypto_tls_creds_get_path(&VAR_0->parent_obj,
QCRYPTO_TLS_CREDS_X509_CA_CERT,
true, &VAR_2, VAR_1) < 0 ||
qcrypto_tls_creds_get_path(&VAR_0->parent_obj,
QCRYPTO_TLS_CREDS_X509_CA_CRL,
false, &VAR_3, VAR_1) < 0 ||
qcrypto_tls_creds_get_path(&VAR_0->parent_obj,
QCRYPTO_TLS_CREDS_X509_SERVER_CERT,
true, &VAR_4, VAR_1) < 0 ||
qcrypto_tls_creds_get_path(&VAR_0->parent_obj,
QCRYPTO_TLS_CREDS_X509_SERVER_KEY,
true, &VAR_5, VAR_1) < 0 ||
qcrypto_tls_creds_get_path(&VAR_0->parent_obj,
QCRYPTO_TLS_CREDS_DH_PARAMS,
false, &VAR_6, VAR_1) < 0) { } else { if (qcrypto_tls_creds_get_path(&VAR_0->parent_obj,
QCRYPTO_TLS_CREDS_X509_CA_CERT,
true, &VAR_2, VAR_1) < 0 ||
qcrypto_tls_creds_get_path(&VAR_0->parent_obj,
QCRYPTO_TLS_CREDS_X509_CLIENT_CERT,
false, &VAR_4, VAR_1) < 0 ||
qcrypto_tls_creds_get_path(&VAR_0->parent_obj,
QCRYPTO_TLS_CREDS_X509_CLIENT_KEY,
false, &VAR_5, VAR_1) < 0) { VAR_7 = gnutls_certificate_allocate_credentials(&VAR_0->data); if (VAR_7 < 0) { error_setg(VAR_1, "Cannot allocate credentials: '%s'",
gnutls_strerror(VAR_7)); VAR_7 = gnutls_certificate_set_x509_trust_file(VAR_0->data,
VAR_2,
GNUTLS_X509_FMT_PEM); if (VAR_7 < 0) { error_setg(VAR_1, "Cannot load CA certificate '%s': %s",
VAR_2, gnutls_strerror(VAR_7)); if (VAR_4 != NULL && VAR_5 != NULL) { VAR_7 = gnutls_certificate_set_x509_key_file(VAR_0->data,
VAR_4, VAR_5,
GNUTLS_X509_FMT_PEM); if (VAR_7 < 0) { error_setg(VAR_1, "Cannot load certificate '%s' & VAR_5 '%s': %s",
VAR_4, VAR_5, gnutls_strerror(VAR_7)); if (VAR_3 != NULL) { VAR_7 = gnutls_certificate_set_x509_crl_file(VAR_0->data,
VAR_3,
GNUTLS_X509_FMT_PEM); if (VAR_7 < 0) { error_setg(VAR_1, "Cannot load CRL '%s': %s",
VAR_3, gnutls_strerror(VAR_7)); if (VAR_0->parent_obj.endpoint == QCRYPTO_TLS_CREDS_ENDPOINT_SERVER) { if (qcrypto_tls_creds_get_dh_params_file(&VAR_0->parent_obj, VAR_6,
&VAR_0->parent_obj.dh_params,
VAR_1) < 0) { gnutls_certificate_set_dh_params(VAR_0->data,
VAR_0->parent_obj.dh_params); VAR_8 = 0; cleanup:
g_free(VAR_2); g_free(VAR_3); g_free(VAR_4); g_free(VAR_5); g_free(VAR_6); return VAR_8;