- if (!noout && !cert)
- {
- if (outformat == FORMAT_ASN1)
- i=(int)i2d_SSL_SESSION_bio(out,x);
- else if (outformat == FORMAT_PEM)
- i=PEM_write_bio_SSL_SESSION(out,x);
- else {
- BIO_printf(bio_err,"bad output format specified for outfile\n");
- goto end;
- }
- if (!i) {
- BIO_printf(bio_err,"unable to write SSL_SESSION\n");
- goto end;
- }
- }
- else if (!noout && (x->peer != NULL)) /* just print the certificate */
- {
- if (outformat == FORMAT_ASN1)
- i=(int)i2d_X509_bio(out,x->peer);
- else if (outformat == FORMAT_PEM)
- i=PEM_write_bio_X509(out,x->peer);
- else {
- BIO_printf(bio_err,"bad output format specified for outfile\n");
- goto end;
- }
- if (!i) {
- BIO_printf(bio_err,"unable to write X509\n");
- goto end;
- }
- }
- ret=0;
-end:
- if (out != NULL) BIO_free(out);
- if (x != NULL) SSL_SESSION_free(x);
- EXIT(ret);
- }
+ if (!noout && !cert) {
+ if (outformat == FORMAT_ASN1)
+ i = i2d_SSL_SESSION_bio(out, x);
+ else if (outformat == FORMAT_PEM)
+ i = PEM_write_bio_SSL_SESSION(out, x);
+ else {
+ BIO_printf(bio_err, "bad output format specified for outfile\n");
+ goto end;
+ }
+ if (!i) {
+ BIO_printf(bio_err, "unable to write SSL_SESSION\n");
+ goto end;
+ }
+ } else if (!noout && (peer != NULL)) { /* just print the certificate */
+ if (outformat == FORMAT_ASN1)
+ i = (int)i2d_X509_bio(out, peer);
+ else if (outformat == FORMAT_PEM)
+ i = PEM_write_bio_X509(out, peer);
+ else {
+ BIO_printf(bio_err, "bad output format specified for outfile\n");
+ goto end;
+ }
+ if (!i) {
+ BIO_printf(bio_err, "unable to write X509\n");
+ goto end;
+ }
+ }
+ ret = 0;
+ end:
+ if (out != NULL)
+ BIO_free_all(out);
+ if (x != NULL)
+ SSL_SESSION_free(x);
+ apps_shutdown();
+ OPENSSL_EXIT(ret);
+}