71593db26bb6ef7b739cffe06d53bf990cac112cwyllys * CDDL HEADER START
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys * The contents of this file are subject to the terms of the
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys * Common Development and Distribution License (the "License").
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys * You may not use this file except in compliance with the License.
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys * See the License for the specific language governing permissions
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys * and limitations under the License.
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys * When distributing Covered Code, include this CDDL HEADER in each
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys * If applicable, add the following below this CDDL HEADER, with the
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys * fields enclosed by brackets "[]" replaced with your own identifying
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys * information: Portions Copyright [yyyy] [name of copyright owner]
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys * CDDL HEADER END
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys * Use is subject to license terms.
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys#pragma ident "%Z%%M% %I% %E% SMI"
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys * Extract the Certificate and raw key data from a PKCS#12 file.
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys * The password needed for decrypting the PKCS#12 PDU is stored
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys * in plaintext in the given "password_file" parameter.
30a5e8fa1253cb33980ee4514743cf683f584b4ewyllys sizeof (password_buf)) <= 0) {
30a5e8fa1253cb33980ee4514743cf683f584b4ewyllys rv = kmf_import_objects(kmfh, (char *)filename, &pk12cred, &tcerts,
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys REPORT_KMF_ERROR(rv, "Error importing PKCS12 data", err);
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys for (i = 0; i < ncerts; i++)
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys for (i = 0; i < nkeys; i++)
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys * Parse a PEM file which should contain RSA private keys and
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys * their associated X.509v3 certificates. More than 1 may
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys * be present in the file.
30a5e8fa1253cb33980ee4514743cf683f584b4ewyllys sizeof (password_buf)) <= 0) {
30a5e8fa1253cb33980ee4514743cf683f584b4ewyllys rv = kmf_import_objects(kmfh, (char *)filename, &creds, &tcerts,
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys REPORT_KMF_ERROR(rv, "Error importing key data", err);
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys for (i = 0; i < ncerts; i++)
71593db26bb6ef7b739cffe06d53bf990cac112cwyllys for (i = 0; i < nkeys; i++)