summaryrefslogtreecommitdiff
path: root/src/usr.bin/openssl/nseq.c
diff options
context:
space:
mode:
authortb <>2023-04-25 16:11:02 +0000
committertb <>2023-04-25 16:11:02 +0000
commit0d93f23822e7889e043d8a9e07ab66b33b45dd53 (patch)
tree2b03158b79a916af2d07cae674152288709c99c9 /src/usr.bin/openssl/nseq.c
parentd05ab2065f197a796d440b6d16c5a157ecfc3531 (diff)
downloadopenbsd-0d93f23822e7889e043d8a9e07ab66b33b45dd53.tar.gz
openbsd-0d93f23822e7889e043d8a9e07ab66b33b45dd53.tar.bz2
openbsd-0d93f23822e7889e043d8a9e07ab66b33b45dd53.zip
Remove the nseq command
Diffstat (limited to 'src/usr.bin/openssl/nseq.c')
-rw-r--r--src/usr.bin/openssl/nseq.c174
1 files changed, 0 insertions, 174 deletions
diff --git a/src/usr.bin/openssl/nseq.c b/src/usr.bin/openssl/nseq.c
deleted file mode 100644
index fb0dda5dca..0000000000
--- a/src/usr.bin/openssl/nseq.c
+++ /dev/null
@@ -1,174 +0,0 @@
1/* $OpenBSD: nseq.c,v 1.11 2023/03/06 14:32:06 tb Exp $ */
2/* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
3 * project 1999.
4 */
5/* ====================================================================
6 * Copyright (c) 1999 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * licensing@OpenSSL.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#include <stdio.h>
60#include <string.h>
61
62#include "apps.h"
63
64#include <openssl/err.h>
65#include <openssl/pem.h>
66
67static struct {
68 char *infile;
69 char *outfile;
70 int toseq;
71} cfg;
72
73static const struct option nseq_options[] = {
74 {
75 .name = "in",
76 .argname = "file",
77 .desc = "Input file to read from (default stdin)",
78 .type = OPTION_ARG,
79 .opt.arg = &cfg.infile,
80 },
81 {
82 .name = "out",
83 .argname = "file",
84 .desc = "Output file to write to (default stdout)",
85 .type = OPTION_ARG,
86 .opt.arg = &cfg.outfile,
87 },
88 {
89 .name = "toseq",
90 .desc = "Convert certificates to Netscape certificate sequence",
91 .type = OPTION_FLAG,
92 .opt.flag = &cfg.toseq,
93 },
94 { NULL },
95};
96
97static void
98nseq_usage()
99{
100 fprintf(stderr, "usage: nseq [-in file] [-out file] [-toseq]\n");
101 options_usage(nseq_options);
102}
103
104int
105nseq_main(int argc, char **argv)
106{
107 BIO *in = NULL, *out = NULL;
108 X509 *x509 = NULL;
109 NETSCAPE_CERT_SEQUENCE *seq = NULL;
110 int i, ret = 1;
111
112 if (pledge("stdio cpath wpath rpath", NULL) == -1) {
113 perror("pledge");
114 exit(1);
115 }
116
117 memset(&cfg, 0, sizeof(cfg));
118
119 if (options_parse(argc, argv, nseq_options, NULL, NULL) != 0) {
120 nseq_usage();
121 return (1);
122 }
123
124 if (cfg.infile) {
125 if (!(in = BIO_new_file(cfg.infile, "r"))) {
126 BIO_printf(bio_err,
127 "Can't open input file %s\n", cfg.infile);
128 goto end;
129 }
130 } else
131 in = BIO_new_fp(stdin, BIO_NOCLOSE);
132
133 if (cfg.outfile) {
134 if (!(out = BIO_new_file(cfg.outfile, "w"))) {
135 BIO_printf(bio_err,
136 "Can't open output file %s\n", cfg.outfile);
137 goto end;
138 }
139 } else {
140 out = BIO_new_fp(stdout, BIO_NOCLOSE);
141 }
142 if (cfg.toseq) {
143 seq = NETSCAPE_CERT_SEQUENCE_new();
144 seq->certs = sk_X509_new_null();
145 while ((x509 = PEM_read_bio_X509(in, NULL, NULL, NULL)))
146 sk_X509_push(seq->certs, x509);
147
148 if (!sk_X509_num(seq->certs)) {
149 BIO_printf(bio_err, "Error reading certs file %s\n", cfg.infile);
150 ERR_print_errors(bio_err);
151 goto end;
152 }
153 PEM_write_bio_NETSCAPE_CERT_SEQUENCE(out, seq);
154 ret = 0;
155 goto end;
156 }
157 if (!(seq = PEM_read_bio_NETSCAPE_CERT_SEQUENCE(in, NULL, NULL, NULL))) {
158 BIO_printf(bio_err, "Error reading sequence file %s\n", cfg.infile);
159 ERR_print_errors(bio_err);
160 goto end;
161 }
162 for (i = 0; i < sk_X509_num(seq->certs); i++) {
163 x509 = sk_X509_value(seq->certs, i);
164 dump_cert_text(out, x509);
165 PEM_write_bio_X509(out, x509);
166 }
167 ret = 0;
168 end:
169 BIO_free(in);
170 BIO_free_all(out);
171 NETSCAPE_CERT_SEQUENCE_free(seq);
172
173 return (ret);
174}