diff --git a/panda/src/express/multifile.cxx b/panda/src/express/multifile.cxx index 9ab3ab2395..3d8b3be7ce 100644 --- a/panda/src/express/multifile.cxx +++ b/panda/src/express/multifile.cxx @@ -988,6 +988,7 @@ get_num_signatures() const { //////////////////////////////////////////////////////////////////// const Multifile::CertChain &Multifile:: get_signature(int n) const { + ((Multifile *)this)->check_signatures(); static CertChain error_chain; nassertr(n >= 0 && n < (int)_signatures.size(), error_chain); return _signatures[n]; @@ -1127,13 +1128,36 @@ get_signature_public_key(int n) const { } #endif // HAVE_OPENSSL +#ifdef HAVE_OPENSSL +//////////////////////////////////////////////////////////////////// +// Function: Multifile::print_signature_certificate +// Access: Published +// Description: Writes the certificate for the nth signature, in +// user-readable verbose form, to the indicated stream. +// See the comments in get_num_signatures(). +//////////////////////////////////////////////////////////////////// +void Multifile:: +print_signature_certificate(int n, ostream &out) const { + const CertChain &cert_chain = get_signature(n); + nassertv(!cert_chain.empty()); + + BIO *mbio = BIO_new(BIO_s_mem()); + X509_print(mbio, cert_chain[0]._cert); + + char *pp; + long pp_size = BIO_get_mem_data(mbio, &pp); + out.write(pp, pp_size); + BIO_free(mbio); +} +#endif // HAVE_OPENSSL + #ifdef HAVE_OPENSSL //////////////////////////////////////////////////////////////////// // Function: Multifile::write_signature_certificate // Access: Published // Description: Writes the certificate for the nth signature, in -// verbose form, to the indicated stream. See the -// comments in get_num_signatures(). +// PEM form, to the indicated stream. See the comments +// in get_num_signatures(). //////////////////////////////////////////////////////////////////// void Multifile:: write_signature_certificate(int n, ostream &out) const { @@ -1141,7 +1165,13 @@ write_signature_certificate(int n, ostream &out) const { nassertv(!cert_chain.empty()); BIO *mbio = BIO_new(BIO_s_mem()); - X509_print(mbio, cert_chain[0]._cert); + + CertChain::const_iterator ci; + for (ci = cert_chain.begin(); ci != cert_chain.end(); ++ci) { + X509 *c = (*ci)._cert; + X509_print(mbio, c); + PEM_write_bio_X509(mbio, c); + } char *pp; long pp_size = BIO_get_mem_data(mbio, &pp); diff --git a/panda/src/express/multifile.h b/panda/src/express/multifile.h index 4c2a77e84a..5a90c17be6 100644 --- a/panda/src/express/multifile.h +++ b/panda/src/express/multifile.h @@ -108,6 +108,7 @@ PUBLISHED: string get_signature_subject_name(int n) const; string get_signature_friendly_name(int n) const; string get_signature_public_key(int n) const; + void print_signature_certificate(int n, ostream &out) const; void write_signature_certificate(int n, ostream &out) const; int validate_signature_certificate(int n) const;