Skip to content

Commit a70760e

Browse files
authored
Merge pull request #428 from embhorn/certgen_cleanup
Fix up readme and build issues in certgen examples
2 parents 17f1b3d + 20d13d8 commit a70760e

5 files changed

Lines changed: 29 additions & 11 deletions

File tree

certgen/README.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Certificate Generation and Signing examples
22

33
To test the certgen or csr_example example(s) configure wolfssl with
4-
`./configure --enable-certgen --enable-certreq` or add the defines:
4+
`./configure --enable-certgen --enable-certreq --enable-keygen`
5+
or add the defines:
56

67
```
78
#define WOLFSSL_CERT_REQ
89
#define WOLFSSL_CERT_GEN
10+
#define WOLFSSL_KEY_GEN
911
```
1012

1113
To test the csr_w_ed25519_example configure wolfssl with:
@@ -156,6 +158,18 @@ Saved CSR PEM to "ed25519-csr.pem"
156158

157159
This example shows how to use a CSR to sign it using a CA cert and key to produce an X.509 certificate.
158160

161+
To test the csr_sign example configure wolfssl with
162+
`./configure -enable-certreq --enable-certgen --enable-ecc --enable-certext CFLAGS=-DOPENSSL_EXTRA_X509_SMALL`
163+
or add the defines:
164+
165+
```
166+
#define WOLFSSL_CERT_REQ
167+
#define WOLFSSL_CERT_GEN
168+
#define WOLFSSL_KEY_GEN
169+
#define WOLFSSL_CERT_EXT
170+
#define OPENSSL_EXTRA_X509_SMALL
171+
```
172+
159173
```
160174
% ./csr_sign ecc-csr.pem ca-ecc-cert.der ca-ecc-key.der
161175
Loading CA certificate
@@ -348,7 +362,7 @@ Tested with these wolfSSL build options:
348362

349363
```sh
350364
./autogen.sh # If cloned from GitHub
351-
./configure --enable-asn=template --enable-certreq --enable-keygen --enable-certgen --enable-certext CFLAGS="-DWOLFSSL_TEST_CERT -DHAVE_OID_DECODING -DHAVE_OID_ENCODING -DWOLFSSL_CUSTOM_OID -DWOLFSSL_CERT_EXT"
365+
./configure --enable-certreq --enable-certext --enable-keygen --enable-certgen --enable-certext CFLAGS="-DWOLFSSL_TEST_CERT -DHAVE_OID_DECODING -DHAVE_OID_ENCODING -DWOLFSSL_CUSTOM_OID"
352366
make
353367
make check
354368
sudo make install

certgen/certgen_ca_example.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,16 @@
2828
#include <wolfssl/wolfcrypt/error-crypt.h>
2929
#include <wolfssl/wolfcrypt/wc_port.h>
3030

31+
#if defined(WOLFSSL_CERT_REQ) && defined(WOLFSSL_CERT_GEN) && \
32+
defined(WOLFSSL_KEY_GEN) && defined(HAVE_ECC)
33+
3134
#ifdef WOLFSSL_CAAM
3235
#include <wolfssl/wolfcrypt/port/caam/wolfcaam.h>
3336
static int devId = WOLFSSL_CAAM_DEVID;
3437
#else
3538
static int devId = INVALID_DEVID;
3639
#endif
3740

38-
#if defined(WOLFSSL_CERT_REQ) && defined(WOLFSSL_CERT_GEN) && \
39-
defined(WOLFSSL_KEY_GEN) && defined(HAVE_ECC)
4041

4142
#define HEAP_HINT NULL
4243
#define LARGE_TEMP_SZ 4096

certgen/csr_sign.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#endif
3535

3636
#if defined(WOLFSSL_CERT_REQ) && defined(WOLFSSL_CERT_GEN) && \
37-
defined(HAVE_ECC)
37+
defined(HAVE_ECC) && defined(WOLFSSL_CERT_EXT)
3838

3939
#define HEAP_HINT NULL
4040
#define LARGE_TEMP_SZ 4096
@@ -358,9 +358,9 @@ static int do_csrsign(int argc, char** argv)
358358
int main(int argc, char** argv)
359359
{
360360
#if !defined(WOLFSSL_CERT_REQ) || !defined(WOLFSSL_CERT_GEN) || \
361-
!defined(HAVE_ECC)
361+
!defined(HAVE_ECC) || !defined(WOLFSSL_CERT_EXT)
362362
printf("Please compile wolfSSL with --enable-certreq --enable-certgen "
363-
"--enable-ecc CFLAGS=-DOPENSSL_EXTRA_X509_SMALL\n");
363+
"--enable-ecc --enable-certext CFLAGS=-DOPENSSL_EXTRA_X509_SMALL\n");
364364
return 0;
365365
#else
366366
if (argc != 4) {

certgen/custom_ext.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,9 @@ int main(int argc, char** argv)
250250

251251
int main(int argc, char** argv)
252252
{
253-
printf("Please compile wolfSSL with --enable-asn=template --enable-certgen "
254-
"--enable-keygen CFLAGS=\"-DWOLFSSL_CUSTOM_OID -DHAVE_OID_ENCODING "
255-
"-DWOLFSSL_CERT_EXT\"");
253+
printf("Please configure wolfSSL with --enable-certgen --enable-certext "
254+
"--enable-keygen CFLAGS=\"-DWOLFSSL_CUSTOM_OID "
255+
"-DHAVE_OID_ENCODING\"\n");
256256
return 0;
257257
}
258258

certgen/custom_ext_callback.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,10 @@ static void check_ret(char* call, int ret)
143143

144144
int main(void)
145145
{
146-
printf("Not compiled in: Build wolfSSL using ./configure --enable-asn=template --enable-certreq --enable-certgen CFLAGS=\"-DWOLFSSL_TEST_CERT -DHAVE_OID_DECODING -DWOLFSSL_CUSTOM_OID -DWOLFSSL_CERT_EXT\"\n");
146+
printf("Not compiled in: Configure wolfSSL using ./configure"
147+
"--enable-certreq --enable-certgen --enable-certext "
148+
"CFLAGS=\"-DWOLFSSL_TEST_CERT -DHAVE_OID_DECODING "
149+
"-DWOLFSSL_CUSTOM_OID \"\n");
147150
return 0;
148151
}
149152

0 commit comments

Comments
 (0)