cert.c revision bf01e8179cbb2be476805340636098deda7e1366
57e3b63a75335f45cf6cf9cd89317e2e6cec249dStephan Bosch SSSD - certificate handling utils - openssl version
57e3b63a75335f45cf6cf9cd89317e2e6cec249dStephan Bosch Copyright (C) Sumit Bose <sbose@redhat.com> 2015
57e3b63a75335f45cf6cf9cd89317e2e6cec249dStephan Bosch This program is free software; you can redistribute it and/or modify
57e3b63a75335f45cf6cf9cd89317e2e6cec249dStephan Bosch it under the terms of the GNU General Public License as published by
57e3b63a75335f45cf6cf9cd89317e2e6cec249dStephan Bosch the Free Software Foundation; either version 3 of the License, or
57e3b63a75335f45cf6cf9cd89317e2e6cec249dStephan Bosch (at your option) any later version.
57e3b63a75335f45cf6cf9cd89317e2e6cec249dStephan Bosch This program is distributed in the hope that it will be useful,
57e3b63a75335f45cf6cf9cd89317e2e6cec249dStephan Bosch but WITHOUT ANY WARRANTY; without even the implied warranty of
042a58438dc324c6d4de18e4c8a68044d6328e66Stephan Bosch MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
042a58438dc324c6d4de18e4c8a68044d6328e66Stephan Bosch GNU General Public License for more details.
042a58438dc324c6d4de18e4c8a68044d6328e66Stephan Bosch You should have received a copy of the GNU General Public License
042a58438dc324c6d4de18e4c8a68044d6328e66Stephan Bosch along with this program. If not, see <http://www.gnu.org/licenses/>.
57e3b63a75335f45cf6cf9cd89317e2e6cec249dStephan Boscherrno_t sss_cert_der_to_pem(TALLOC_CTX *mem_ctx, const uint8_t *der_blob,
57e3b63a75335f45cf6cf9cd89317e2e6cec249dStephan Bosch size_t der_size, char **pem, size_t *pem_size)
57e3b63a75335f45cf6cf9cd89317e2e6cec249dStephan Bosch const unsigned char *d;
57e3b63a75335f45cf6cf9cd89317e2e6cec249dStephan Bosch d = (const unsigned char *) der_blob;
89bc31f70e51f4a69e0444c4f893831f6e96456eTimo Sirainen DEBUG(SSSDBG_OP_FAILURE, "d2i_X509 failed.\n");
57e3b63a75335f45cf6cf9cd89317e2e6cec249dStephan Bosch DEBUG(SSSDBG_OP_FAILURE, "BIO_new failed.\n");
57e3b63a75335f45cf6cf9cd89317e2e6cec249dStephan Bosch DEBUG(SSSDBG_OP_FAILURE, "PEM_write_bio_X509 failed.\n");
57e3b63a75335f45cf6cf9cd89317e2e6cec249dStephan Bosch DEBUG(SSSDBG_OP_FAILURE, "Unexpected PEM size [%ld].\n", p_size);
6407243c0b7340dd7b53b96bcb8e6b0e1acdb104Stephan Bosch DEBUG(SSSDBG_OP_FAILURE, "talloc_memdup failed.\n");
6407243c0b7340dd7b53b96bcb8e6b0e1acdb104Stephan Boscherrno_t sss_cert_pem_to_der(TALLOC_CTX *mem_ctx, const char *pem,
57e3b63a75335f45cf6cf9cd89317e2e6cec249dStephan Bosch unsigned char *buf;
57e3b63a75335f45cf6cf9cd89317e2e6cec249dStephan Bosch DEBUG(SSSDBG_OP_FAILURE, "BIO_new failed.\n");
57e3b63a75335f45cf6cf9cd89317e2e6cec249dStephan Bosch DEBUG(SSSDBG_OP_FAILURE, "BIO_puts failed.\n");
57e3b63a75335f45cf6cf9cd89317e2e6cec249dStephan Bosch x509 = PEM_read_bio_X509(bio_mem, NULL, NULL, NULL);
57e3b63a75335f45cf6cf9cd89317e2e6cec249dStephan Bosch DEBUG(SSSDBG_OP_FAILURE, "PEM_read_bio_X509 failed.\n");
57e3b63a75335f45cf6cf9cd89317e2e6cec249dStephan Bosch DEBUG(SSSDBG_OP_FAILURE, "i2d_X509 failed.\n");
57e3b63a75335f45cf6cf9cd89317e2e6cec249dStephan Bosch DEBUG(SSSDBG_OP_FAILURE, "talloc_size failed.\n");
57e3b63a75335f45cf6cf9cd89317e2e6cec249dStephan Bosch "i2d_X509 size mismatch between two calls.\n");