* The @key may be %NULL if you are using a sign callback, see
* gnutls_sign_callback_set().
*
- * Returns: %GNUTLS_E_SUCCESS (0) on success, or a negative error code.
+ * Returns: An index of the inserted certificate chain on success (greater or equal to zero), or a negative error code.
**/
int
gnutls_certificate_set_x509_key_mem(gnutls_certificate_credentials_t res,
* The @key may be %NULL if you are using a sign callback, see
* gnutls_sign_callback_set().
*
- * Returns: %GNUTLS_E_SUCCESS (0) on success, or a negative error code.
+ * Returns: An index of the inserted certificate chain on success (greater or equal to zero), or a negative error code.
**/
int
gnutls_certificate_set_x509_key_mem2(gnutls_certificate_credentials_t res,
return ret;
}
- return 0;
+ /* return the index of the chain */
+ return res->ncerts-1;
}
int
* If that function fails to load the @res type is at an undefined state, it must
* not be reused to load other keys or certificates.
*
- * Returns: %GNUTLS_E_SUCCESS (0) on success, or a negative error code.
+ * Returns: An index of the inserted certificate chain on success (greater or equal to zero), or a negative error code.
*
* Since: 2.4.0
**/
goto cleanup;
}
- return 0;
+ return res->ncerts-1;
cleanup:
gnutls_free(pcerts);
* If there is no key with the given index,
* %GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE is returned. If the key with the
* given index is not a X.509 key, %GNUTLS_E_INVALID_REQUEST is returned.
+ * The @index matches the value gnutls_certificate_set_x509_key() and friends
+ * functions.
*
* Returns: %GNUTLS_E_SUCCESS (0) on success, or a negative error code.
*
* certificate list must be deallocated with gnutls_x509_crt_deinit(), and the
* list itself must be freed with gnutls_free().
*
- * If there is no certificate with the given index,
+ * The @index matches the value gnutls_certificate_set_x509_key() and friends
+ * functions. If there is no certificate with the given index,
* %GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE is returned. If the certificate
* with the given index is not a X.509 certificate, %GNUTLS_E_INVALID_REQUEST
* is returned. The returned certificates must be deinitialized after
* This function sets a certificate/private key pair in the
* gnutls_certificate_credentials_t type. This function may be
* called more than once, in case multiple keys/certificates exist for
- * the server. For clients that wants to send more than its own end
- * entity certificate (e.g., also an intermediate CA cert) then put
- * the certificate chain in @pcert_list.
+ * the server. For clients that want to send more than their own end-
+ * entity certificate (e.g., also an intermediate CA cert), the full
+ * certificate chain must be provided in @pcert_list.
*
* Note that the @key and the elements of @pcert_list will become part of the credentials
* structure and must not be deallocated. They will be automatically deallocated
- * when the @res type is deinitialized.
+ * when the @res structure is deinitialized.
*
* If that function fails to load the @res structure is at an undefined state, it must
* not be reused to load other keys or certificates.
*
- * Returns: %GNUTLS_E_SUCCESS (0) on success, or a negative error code.
+ * Returns: An index of the inserted certificate chain on success (greater or equal to zero), or a negative error code.
*
* Since: 3.0
**/
return ret;
}
- return 0;
+ return res->ncerts-1;
cleanup:
_gnutls_str_array_clear(&str_names);
* If that function fails to load the @res structure is at an undefined state, it must
* not be reused to load other keys or certificates.
*
- * Returns: %GNUTLS_E_SUCCESS (0) on success, or a negative error code.
+ * Returns: An index of the inserted certificate chain on success (greater or equal to zero), or a negative error code.
*
* Since: 3.1.11
**/
* If that function fails to load the @res structure is at an undefined state, it must
* not be reused to load other keys or certificates.
*
- * Returns: %GNUTLS_E_SUCCESS (0) on success, or a negative error code.
+ * Returns: An index of the inserted certificate chain on success (greater or equal to zero), or a negative error code.
+ *
**/
int
gnutls_certificate_set_x509_key_file2(gnutls_certificate_credentials_t res,
return ret;
}
- return 0;
+ return res->ncerts-1;
}
/* Returns 0 if it's ok to use the gnutls_kx_algorithm_t with this
* complexity that would make it harder to use this functionality at
* all.
*
- * Returns: %GNUTLS_E_SUCCESS (0) on success, or a negative error code.
+ * Returns: An index of the inserted certificate chain on success (greater or equal to zero), or a negative error code.
+ *
**/
int
gnutls_certificate_set_x509_simple_pkcs12_file
* complexity that would make it harder to use this functionality at
* all.
*
- * Returns: %GNUTLS_E_SUCCESS (0) on success, or a negative error code.
+ * Returns: An index of the inserted certificate chain on success (greater or equal to zero), or a negative error code.
*
* Since: 2.8.0
**/
gnutls_x509_crt_t *chain = NULL;
gnutls_x509_crl_t crl = NULL;
unsigned int chain_size = 0, i;
- int ret;
+ int ret, idx;
ret = gnutls_pkcs12_init(&p12);
if (ret < 0) {
gnutls_assert();
goto done;
}
+
+ idx = ret;
} else {
gnutls_assert();
ret = GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE;
}
}
- ret = 0;
+ ret = idx;
done:
if (chain) {