OLD | NEW |
1 /* ssl/ssl_rsa.c */ | 1 /* ssl/ssl_rsa.c */ |
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * This package is an SSL implementation written | 5 * This package is an SSL implementation written |
6 * by Eric Young (eay@cryptsoft.com). | 6 * by Eric Young (eay@cryptsoft.com). |
7 * The implementation was written so as to conform with Netscapes SSL. | 7 * The implementation was written so as to conform with Netscapes SSL. |
8 * | 8 * |
9 * This library is free for commercial and non-commercial use as long as | 9 * This library is free for commercial and non-commercial use as long as |
10 * the following conditions are aheared to. The following conditions | 10 * the following conditions are aheared to. The following conditions |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 SSLerr(SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1,ERR_R_ASN1_LIB); | 690 SSLerr(SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1,ERR_R_ASN1_LIB); |
691 return(0); | 691 return(0); |
692 } | 692 } |
693 | 693 |
694 ret=SSL_CTX_use_PrivateKey(ctx,pkey); | 694 ret=SSL_CTX_use_PrivateKey(ctx,pkey); |
695 EVP_PKEY_free(pkey); | 695 EVP_PKEY_free(pkey); |
696 return(ret); | 696 return(ret); |
697 } | 697 } |
698 | 698 |
699 | 699 |
| 700 int SSL_use_certificate_chain(SSL *ssl, STACK_OF(X509) *cert_chain) |
| 701 { |
| 702 if (ssl == NULL) |
| 703 { |
| 704 SSLerr(SSL_F_SSL_USE_CERTIFICATE_CHAIN,ERR_R_PASSED_NULL_PARAMET
ER); |
| 705 return(0); |
| 706 } |
| 707 if (ssl->cert == NULL) |
| 708 { |
| 709 SSLerr(SSL_F_SSL_USE_CERTIFICATE_CHAIN,SSL_R_NO_CERTIFICATE_ASSI
GNED); |
| 710 return(0); |
| 711 } |
| 712 if (ssl->cert->key == NULL) |
| 713 { |
| 714 SSLerr(SSL_F_SSL_USE_CERTIFICATE_CHAIN,SSL_R_NO_CERTIFICATE_ASSI
GNED); |
| 715 return(0); |
| 716 } |
| 717 ssl->cert->key->cert_chain = cert_chain; |
| 718 return(1); |
| 719 } |
| 720 |
| 721 STACK_OF(X509) *SSL_get_certificate_chain(SSL *ssl, X509 *x) |
| 722 { |
| 723 int i; |
| 724 if (x == NULL) |
| 725 return NULL; |
| 726 if (ssl == NULL) |
| 727 return NULL; |
| 728 if (ssl->cert == NULL) |
| 729 return NULL; |
| 730 for (i = 0; i < SSL_PKEY_NUM; i++) |
| 731 if (ssl->cert->pkeys[i].x509 == x) |
| 732 return ssl->cert->pkeys[i].cert_chain; |
| 733 return NULL; |
| 734 } |
| 735 |
700 #ifndef OPENSSL_NO_STDIO | 736 #ifndef OPENSSL_NO_STDIO |
701 /* Read a file that contains our certificate in "PEM" format, | 737 /* Read a file that contains our certificate in "PEM" format, |
702 * possibly followed by a sequence of CA certificates that should be | 738 * possibly followed by a sequence of CA certificates that should be |
703 * sent to the peer in the Certificate message. | 739 * sent to the peer in the Certificate message. |
704 */ | 740 */ |
705 int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file) | 741 int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file) |
706 { | 742 { |
707 BIO *in; | 743 BIO *in; |
708 int ret=0; | 744 int ret=0; |
709 X509 *x=NULL; | 745 X509 *x=NULL; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
770 else | 806 else |
771 ret = 0; /* some real error */ | 807 ret = 0; /* some real error */ |
772 } | 808 } |
773 | 809 |
774 end: | 810 end: |
775 if (x != NULL) X509_free(x); | 811 if (x != NULL) X509_free(x); |
776 if (in != NULL) BIO_free(in); | 812 if (in != NULL) BIO_free(in); |
777 return(ret); | 813 return(ret); |
778 } | 814 } |
779 #endif | 815 #endif |
OLD | NEW |