am 9c64d590: Merge change 23425 into eclair
Merge commit '9c64d59027a09699ec5ef1f0fedd88910ee7ae27' into eclair-plus-aosp * commit '9c64d59027a09699ec5ef1f0fedd88910ee7ae27': Store CA certificate chain into one single key entry with PEM format.
This commit is contained in:
@@ -163,15 +163,9 @@ public class CertTool {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while ((pemData = this.popPkcs12CertificateStack(handle)) != null) {
|
if ((pemData = this.popPkcs12CertificateStack(handle)) != null) {
|
||||||
if (i++ > 0) {
|
if ((ret = sKeystore.put(CA_CERTIFICATE, keyname, pemData)) != 0) {
|
||||||
if ((ret = sKeystore.put(CA_CERTIFICATE, keyname + i, pemData)) != 0) {
|
return ret;
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ((ret = sKeystore.put(CA_CERTIFICATE, keyname, pemData)) != 0) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -212,13 +212,14 @@ static int convert_to_pem(void *data, int is_cert, char *buf, int size)
|
|||||||
}
|
}
|
||||||
err:
|
err:
|
||||||
if (bio) BIO_free(bio);
|
if (bio) BIO_free(bio);
|
||||||
return (len == 0) ? -1 : 0;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get_pkcs12_certificate(PKCS12_KEYSTORE *p12store, char *buf, int size)
|
int get_pkcs12_certificate(PKCS12_KEYSTORE *p12store, char *buf, int size)
|
||||||
{
|
{
|
||||||
if ((p12store != NULL) && (p12store->cert != NULL)) {
|
if ((p12store != NULL) && (p12store->cert != NULL)) {
|
||||||
return convert_to_pem((void*)p12store->cert, 1, buf, size);
|
int len = convert_to_pem((void*)p12store->cert, 1, buf, size);
|
||||||
|
return (len == 0) ? -1 : 0;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -226,7 +227,8 @@ int get_pkcs12_certificate(PKCS12_KEYSTORE *p12store, char *buf, int size)
|
|||||||
int get_pkcs12_private_key(PKCS12_KEYSTORE *p12store, char *buf, int size)
|
int get_pkcs12_private_key(PKCS12_KEYSTORE *p12store, char *buf, int size)
|
||||||
{
|
{
|
||||||
if ((p12store != NULL) && (p12store->pkey != NULL)) {
|
if ((p12store != NULL) && (p12store->pkey != NULL)) {
|
||||||
return convert_to_pem((void*)p12store->pkey, 0, buf, size);
|
int len = convert_to_pem((void*)p12store->pkey, 0, buf, size);
|
||||||
|
return (len == 0) ? -1 : 0;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -234,12 +236,16 @@ int get_pkcs12_private_key(PKCS12_KEYSTORE *p12store, char *buf, int size)
|
|||||||
int pop_pkcs12_certs_stack(PKCS12_KEYSTORE *p12store, char *buf, int size)
|
int pop_pkcs12_certs_stack(PKCS12_KEYSTORE *p12store, char *buf, int size)
|
||||||
{
|
{
|
||||||
X509 *cert = NULL;
|
X509 *cert = NULL;
|
||||||
|
int len = 0;
|
||||||
|
|
||||||
if ((p12store != NULL) && (p12store->certs != NULL) &&
|
if ((p12store != NULL) && (p12store->certs != NULL)) {
|
||||||
((cert = sk_X509_pop(p12store->certs)) != NULL)) {
|
while (((cert = sk_X509_pop(p12store->certs)) != NULL) && (len < size)) {
|
||||||
int ret = convert_to_pem((void*)cert, 1, buf, size);
|
int s = convert_to_pem((void*)cert, 1, buf + len, size - len);
|
||||||
X509_free(cert);
|
if (s == 0) return -1;
|
||||||
return ret;
|
len += s;
|
||||||
|
X509_free(cert);
|
||||||
|
}
|
||||||
|
return (len == 0) ? -1 : 0;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user