-
Notifications
You must be signed in to change notification settings - Fork 1
/
draft-moskowitz-ecdsa-pki.txt
1848 lines (1229 loc) · 58.1 KB
/
draft-moskowitz-ecdsa-pki.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
wg TBD R. Moskowitz
Internet-Draft HTT Consulting
Intended status: Informational H. Birkholz
Expires: February 10, 2021 Fraunhofer SIT
L. Xia
Huawei
M. Richardson
Sandelman
August 9, 2020
Guide for building an ECC pki
draft-moskowitz-ecdsa-pki-09
Abstract
This memo provides a guide for building a PKI (Public Key
Infrastructure) using openSSL. All certificates in this guide are
ECDSA, P-256, with SHA256 certificates. Along with common End Entity
certificates, this guide provides instructions for creating IEEE
802.1AR iDevID Secure Device certificates.
Status of This Memo
This Internet-Draft is submitted in full conformance with the
provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering
Task Force (IETF). Note that other groups may also distribute
working documents as Internet-Drafts. The list of current Internet-
Drafts is at https://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any
time. It is inappropriate to use Internet-Drafts as reference
material or to cite them other than as "work in progress."
This Internet-Draft will expire on February 10, 2021.
Copyright Notice
Copyright (c) 2020 IETF Trust and the persons identified as the
document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal
Provisions Relating to IETF Documents
(https://trustee.ietf.org/license-info) in effect on the date of
publication of this document. Please review these documents
Moskowitz, et al. Expires February 10, 2021 [Page 1]
Internet-Draft PKI Guide August 2020
carefully, as they describe your rights and restrictions with respect
to this document. Code Components extracted from this document must
include Simplified BSD License text as described in Section 4.e of
the Trust Legal Provisions and are provided without warranty as
described in the Simplified BSD License.
Table of Contents
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3
2. Terms and Definitions . . . . . . . . . . . . . . . . . . . . 3
2.1. Requirements Terminology . . . . . . . . . . . . . . . . 3
2.2. Notations . . . . . . . . . . . . . . . . . . . . . . . . 3
2.3. Definitions . . . . . . . . . . . . . . . . . . . . . . . 3
3. The Basic PKI feature set . . . . . . . . . . . . . . . . . . 4
4. Getting started and the Root level . . . . . . . . . . . . . 4
4.1. Setting up the Environment . . . . . . . . . . . . . . . 5
4.2. Create the Root Certificate . . . . . . . . . . . . . . . 6
5. The Intermediate level . . . . . . . . . . . . . . . . . . . 7
5.1. Setting up the Intermediate Certificate Environment . . . 7
5.2. Create the Intermediate Certificate . . . . . . . . . . . 8
5.3. Create a Server EE Certificate . . . . . . . . . . . . . 10
5.4. Create a Client EE Certificate . . . . . . . . . . . . . 10
6. The 802.1AR Intermediate level . . . . . . . . . . . . . . . 11
6.1. Setting up the 802.1AR Intermediate Certificate
Environment . . . . . . . . . . . . . . . . . . . . . . . 11
6.2. Create the 802.1AR Intermediate Certificate . . . . . . . 12
6.3. Create an 802.1AR iDevID Certificate . . . . . . . . . . 14
7. Setting up a CRL for an Intermediate CA . . . . . . . . . . . 15
7.1. Create (or recreate) the CRL . . . . . . . . . . . . . . 15
7.2. Revoke a Certificate . . . . . . . . . . . . . . . . . . 15
8. Setting up OCSP for an Intermediate CA . . . . . . . . . . . 16
8.1. Create the OCSP Certificate . . . . . . . . . . . . . . . 16
8.2. Revoke a Certificate . . . . . . . . . . . . . . . . . . 18
8.3. Testing OCSP with Openssl . . . . . . . . . . . . . . . . 18
9. Footnotes . . . . . . . . . . . . . . . . . . . . . . . . . . 19
9.1. Certificate Serial Number . . . . . . . . . . . . . . . . 19
9.2. Some OpenSSL config file limitations . . . . . . . . . . 20
9.3. subjectAltName support, or lack thereof . . . . . . . . . 20
9.4. DER support, or lack thereof . . . . . . . . . . . . . . 20
10. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 21
11. Security Considerations . . . . . . . . . . . . . . . . . . . 21
11.1. Adequate Randomness . . . . . . . . . . . . . . . . . . 21
11.2. Key pair Theft . . . . . . . . . . . . . . . . . . . . . 21
12. Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . 22
13. References . . . . . . . . . . . . . . . . . . . . . . . . . 22
13.1. Normative References . . . . . . . . . . . . . . . . . . 22
13.2. Informative References . . . . . . . . . . . . . . . . . 22
Appendix A. OpenSSL config files . . . . . . . . . . . . . . . . 23
Moskowitz, et al. Expires February 10, 2021 [Page 2]
Internet-Draft PKI Guide August 2020
A.1. OpenSSL Root config file . . . . . . . . . . . . . . . . 23
A.2. OpenSSL Intermediate config file . . . . . . . . . . . . 26
A.3. OpenSSL 802.1AR Intermediate config file . . . . . . . . 29
Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . 32
1. Introduction
The IETF has a plethora of security solutions targeted at IoT. Yet
all too many IoT products are deployed with no or improperly
configured security. In particular resource constrained IoT devices
and non-IP IoT networks have not been well served in the IETF.
Additionally, more IETF (e.g. DOTS, NETCONF) efforts are requiring
secure identities, but are vague on the nature of these identities
other than to recommend use of X.509 digital certificates and perhaps
TLS.
This effort provides the steps, using the openSSL application, to
create such a PKI of ECDSA certificates. The goal is that any
developer or tester can follow these steps, create the basic objects
needed and establish the validity of the standard/program design.
This guide can even be used to create a production PKi, though
additional steps need to be taken. This could be very useful to a
small vendor needing to include 802.1AR [IEEE.802.1AR_2009] iDevIDs
in their product.
This guide was tested with openSSL 1.1.0f on Fedora 26 and creates
PEM-based certificates. DER based certificates fails (see
Section 9.4).
2. Terms and Definitions
2.1. Requirements Terminology
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
"SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
document are to be interpreted as described in RFC 2119 [RFC2119].
2.2. Notations
This section will contain notations
2.3. Definitions
There are no draft specific definitions at this time
Moskowitz, et al. Expires February 10, 2021 [Page 3]
Internet-Draft PKI Guide August 2020
3. The Basic PKI feature set
A basic pki has two levels of hierarchy: Root and Intermediate. The
Root level has the greatest risk, and is the least used. It only
signs the Intermediate level signing certificate. As such, once the
Root level is created and signs the Intermediate level certificate it
can be locked up. In fact, the Root level could exist completely on
a mSD boot card for an ARM small computer like a RaspberryPi. A copy
of this card came be made and securely stored in a different
location.
The Root level contains the Root certificate private key, a database
of all signed certificates, and the public certificate. It can also
contain the Intermediate level public certificate and a Root level
CRL.
The Intermediate level contains the Intermediate certificate private
key, the public certificate, a database of all signed certificates,
the certificate trust chain, and Intermediate level CRL. It can also
contain the End Entity public certificates. The private key file
needs to be keep securely. For example as with the Root level, a mSD
image for an ARM computer could contain the complete Intermediate
level. This image is kept offline. The End Entity CSR is copied to
it, signed, and then the signed certificate and updated database are
moved to the public image that lacks the private key.
For a simple test pki, all files can be kept on a single system that
is managed by the tester.
End Entities create a key pair and a Certificate Signing Request
(CSR). The private key is stored securely. The CSR is delivered to
the Intermediate level which uses the CSR to create the End Entity
certificate. This certificate, along with the trust chain back to
the root, is then returned to the End Entity.
There is more to a pki, but this suffices for most development and
testing needs.
4. Getting started and the Root level
This guide was developed on a Fedora 26 armv7hl system (Cubieboard2
SoC). It should work on most Linux and similar systems. All work
was done in a terminal window with extensive "cutting and pasting"
from a draft guide into the terminal window. Users of this guide may
find different behaviors based on their system.
Moskowitz, et al. Expires February 10, 2021 [Page 4]
Internet-Draft PKI Guide August 2020
4.1. Setting up the Environment
The first step is to create the pki environment. Modify the
variables to suit your needs.
<sourcecode> file "setup1.sh"
# edit directory here, or override
export cadir=${cadir-/root/ca}
export rootca=${cadir}/root
export cfgdir=${cfgdir-$cadir}
export intdir=${cadir}/intermediate
export int1ardir=${cadir}/inter_1ar
export format=pem
export default_crl_days=65
mkdir -p $cadir/certs
mkdir -p $rootca
(cd $rootca
mkdir -p certs crl csr newcerts private
chmod 700 private
touch index.txt index.txt.attr
if [ ! -f serial ]; then echo 00 >serial; fi
)
sn=8
# edit these to suit
countryName="/C=US"
stateOrProvinceName="/ST=MI"
localityName="/L=Oak Park"
organizationName="/O=HTT Consulting"
#organizationalUnitName="/OU="
organizationalUnitName=
commonName="/CN=Root CA"
DN=$countryName$stateOrProvinceName$localityName
DN=$DN$organizationName$organizationalUnitName$commonName
echo $DN
export subjectAltName=email:[email protected]
export default_crl_days=2048
</sourcecode>
Where:
dir
Directory for certificate files
Moskowitz, et al. Expires February 10, 2021 [Page 5]
Internet-Draft PKI Guide August 2020
cadir
Directory for Root certificate files
Format
File encoding: PEM or DER
At this time only PEM works
sn
Serial Number length in bytes
For a public CA the range is 8 to 19
The Serial Number length for a public pki ranges from 8 to 19 bytes.
The use of 19 rather than 20 is to accommodate the hex representation
of the Serial Number. If it has a one in the high order bit, DER
encoding rules will place a 0x00 in front.
The DN and SAN fields are examples. Change them to appropriate
values. If you leave one blank, it will be left out of the
Certificate. "OU" above is an example of an empty DN object.
Create the file, $dir/openssl-root.cnf from the contents in
Appendix A.1.
4.2. Create the Root Certificate
Next are the openssl commands to create the Root certificate keypair,
and the Root certificate. Included are commands to view the file
contents.
Moskowitz, et al. Expires February 10, 2021 [Page 6]
Internet-Draft PKI Guide August 2020
<sourcecode> file "rootcert.sh"
# Create passworded keypair file
if [ ! -f $rootca/private/ca.key.$format ]; then
echo GENERATING KEY
openssl genpkey $pass -aes256 -algorithm ec\
-pkeyopt ec_paramgen_curve:prime256v1\
-outform $format -pkeyopt ec_param_enc:named_curve\
-out $rootca/private/ca.key.$format
chmod 400 $rootca/private/ca.key.$format
openssl pkey $passin -inform $format -in $rootca/private/ca.key.$format\
-text -noout
fi
# Create Self-signed Root Certificate file
# 7300 days = 20 years; Intermediate CA is 10 years.
echo GENERATING and SIGNING REQ
openssl req -config $cfgdir/openssl-root.cnf $passin \
-set_serial 0x$(openssl rand -hex $sn)\
-keyform $format -outform $format\
-key $rootca/private/ca.key.$format -subj "$DN"\
-new -x509 -days 7300 -sha256 -extensions v3_ca\
-out $cadir/certs/ca.cert.$format
#
openssl x509 -inform $format -in $cadir/certs/ca.cert.$format\
-text -noout
openssl x509 -purpose -inform $format\
-in $cadir/certs/ca.cert.$format -inform $format
</sourcecode>
5. The Intermediate level
5.1. Setting up the Intermediate Certificate Environment
The next part is to create the Intermediate pki environment. Modify
the variables to suit your needs. In particular, set the variables
for CRL and/or OCSP support.
Moskowitz, et al. Expires February 10, 2021 [Page 7]
Internet-Draft PKI Guide August 2020
<sourcecode> file "intermediate_setup.sh"
export intdir=${intdir-$cadir/intermediate}
mkdir -p $intdir
(
cd $intdir
mkdir -p certs crl csr newcerts private
chmod 700 private
touch index.txt index.txt.attr
if [ ! -f serial ]; then echo 00 >serial; fi
)
sn=8 # hex 8 is minimum, 19 is maximum
echo 1000 > $intdir/crlnumber
# cd $dir
export crlDP=
# For CRL support use uncomment these:
#crl=intermediate.crl.pem
#crlurl=www.htt-consult.com/pki/$crl
#export crlDP="URI:http://$crlurl"
export default_crl_days=30
export ocspIAI=
# For OCSP support use uncomment these:
#ocspurl=ocsp.htt-consult.com
#export ocspIAI="OCSP;URI:http://$ocspurl"
commonName="/CN=Signing CA"
DN=$countryName$stateOrProvinceName$localityName$organizationName
DN=$DN$organizationalUnitName$commonName
echo $DN
</sourcecode>
Create the file, $dir/openssl-intermediate.cnf from the contents in
Appendix A.2. Uncomment lines for crlDistributionPoints and
authorityInfoAccess if using CRLs or OSCP repectfully.
5.2. Create the Intermediate Certificate
Here are the openssl commands to create the Intermediate certificate
keypair, Intermediate certificate signed request (CSR), and the
Intermediate certificate. Included are commands to view the file
contents.
<sourcecode> file "intermediate_cert.sh"
# Create passworded keypair file
Moskowitz, et al. Expires February 10, 2021 [Page 8]
Internet-Draft PKI Guide August 2020
if [ ! -f $intdir/private/intermediate.key.$format ]; then
echo GENERATING intermediate KEY
openssl genpkey $pass -aes256 -algorithm ec \
-pkeyopt ec_paramgen_curve:prime256v1 \
-outform $format -pkeyopt ec_param_enc:named_curve\
-out $intdir/private/intermediate.key.$format
chmod 400 $intdir/private/intermediate.key.$format
openssl pkey $passin -inform $format\
-in $intdir/private/intermediate.key.$format -text -noout
fi
# Create the CSR
echo GENERATING and SIGNING REQ intermediate
openssl req -config $cfgdir/openssl-root.cnf $passin \
-key $intdir/private/intermediate.key.$format -batch \
-keyform $format -outform $format -subj "$DN" -new -sha256\
-out $intdir/csr/intermediate.csr.$format
openssl req -text -noout -verify -inform $format\
-in $intdir/csr/intermediate.csr.$format
# Create Intermediate Certificate file
openssl rand -hex $sn > $intdir/serial # hex 8 is minimum, 19 is maximum
if [ ! -f $cadir/certs/intermediate.cert.pem ]; then
# Note 'openssl ca' does not support DER format
openssl ca -config $cfgdir/openssl-root.cnf -days 3650 $passin \
-extensions v3_intermediate_ca -notext -md sha256 -batch \
-in $intdir/csr/intermediate.csr.$format\
-out $cadir/certs/intermediate.cert.pem
chmod 444 $cadir/certs/intermediate.cert.$format
rm -f $cadir/certs/ca-chain.cert.$format
fi
openssl verify -CAfile $cadir/certs/ca.cert.$format\
$cadir/certs/intermediate.cert.$format
openssl x509 -noout -text -in $cadir/certs/intermediate.cert.$format
# Create the certificate chain file
if [ ! -f $cadir/certs/ca-chain.cert.$format ]; then
cat $cadir/certs/intermediate.cert.$format\
$cadir/certs/ca.cert.$format > $cadir/certs/ca-chain.cert.$format
chmod 444 $cadir/certs/ca-chain.cert.$format
fi
Moskowitz, et al. Expires February 10, 2021 [Page 9]
Internet-Draft PKI Guide August 2020
</sourcecode>
5.3. Create a Server EE Certificate
Here are the openssl commands to create a Server End Entity
certificate keypair, Server certificate signed request (CSR), and the
Server certificate. Included are commands to view the file contents.
<sourcecode> file "end-server.sh"
commonName=
DN=$countryName$stateOrProvinceName$localityName
DN=$DN$organizationName$organizationalUnitName$commonName
echo $DN
serverfqdn=www.example.com
export subjectAltName="DNS:$serverfqdn, email:$emailaddr"
echo $subjectAltName
openssl genpkey -algorithm ec -pkeyopt ec_paramgen_curve:prime256v1\
-pkeyopt ec_param_enc:named_curve\
-out $dir/private/$serverfqdn.key.$format
chmod 400 $dir/private/$serverfqdn.$format
openssl pkey -in $dir/private/$serverfqdn.key.$format -text -noout
openssl req -config $dir/openssl-intermediate.cnf\
-key $dir/private/$serverfqdn.key.$format \
-subj "$DN" -new -sha256 -out $dir/csr/$serverfqdn.csr.$format
openssl req -text -noout -verify -in $dir/csr/$serverfqdn.csr.$format
openssl rand -hex $sn > $dir/serial # hex 8 is minimum, 19 is maximum
# Note 'openssl ca' does not support DER format
openssl ca -config $dir/openssl-intermediate.cnf -days 375\
-extensions server_cert -notext -md sha256 \
-in $dir/csr/$serverfqdn.csr.$format\
-out $dir/certs/$serverfqdn.cert.$format
chmod 444 $dir/certs/$serverfqdn.cert.$format
openssl verify -CAfile $dir/certs/ca-chain.cert.$format\
$dir/certs/$serverfqdn.cert.$format
openssl x509 -noout -text -in $dir/certs/$serverfqdn.cert.$format
</sourcecode>
5.4. Create a Client EE Certificate
Here are the openssl commands to create a Client End Entity
certificate keypair, Client certificate signed request (CSR), and the
Client certificate. Included are commands to view the file contents.
Moskowitz, et al. Expires February 10, 2021 [Page 10]
Internet-Draft PKI Guide August 2020
<sourcecode> file "end-client-dn.sh"
commonName=
UserID="/UID=rgm"
DN=$countryName$stateOrProvinceName$localityName
DN=$DN$organizationName$organizationalUnitName$commonName$UserID
echo $DN
</sourcecode>
<sourcecode> file "end-client.sh"
export subjectAltName="email:$clientemail"
echo $subjectAltName
if [ ! -f $intdir/private/$clientemail.key.$format ]; then
openssl genpkey $pass -algorithm ec -pkeyopt ec_paramgen_curve:prime256v1\
-pkeyopt ec_param_enc:named_curve\
-out $intdir/private/$clientemail.key.$format
chmod 400 $intdir/private/$clientemail.key.$format
openssl pkey $passin -in $intdir/private/$clientemail.key.$format -text -noout
fi
openssl req -config $cfgdir/openssl-intermediate.cnf $passin \
-key $intdir/private/$clientemail.key.$format \
-subj "$DN" -new -sha256 -out $intdir/csr/$clientemail.csr.$format
openssl req -text -noout -verify\
-in $intdir/csr/$clientemail.csr.$format
openssl rand -hex $sn > $intdir/serial # hex 8 is minimum, 19 is maximum
# Note 'openssl ca' does not support DER format
openssl ca -config $cfgdir/openssl-intermediate.cnf -days 375\
-extensions usr_cert -notext -md sha256 $passin \
-in $intdir/csr/$clientemail.csr.$format -batch\
-out $cadir/certs/$clientemail.cert.$format
chmod 444 $cadir/certs/$clientemail.cert.$format
openssl verify -CAfile $cadir/certs/ca-chain.cert.$format\
$cadir/certs/$clientemail.cert.$format
openssl x509 -noout -text -in $cadir/certs/$clientemail.cert.$format
</sourcecode>
6. The 802.1AR Intermediate level
6.1. Setting up the 802.1AR Intermediate Certificate Environment
The next part is to create the 802.1AR Intermediate pki environment.
This is very similar to the Intermediate pki environment. Modify the
variables to suit your needs.
Moskowitz, et al. Expires February 10, 2021 [Page 11]
Internet-Draft PKI Guide August 2020
<sourcecode> file "intermediate_1ar_setup.sh"
export dir=$cadir/8021ARintermediate
mkdir $dir
cd $dir
mkdir certs crl csr newcerts private
chmod 700 private
touch index.txt
sn=8 # hex 8 is minimum, 19 is maximum
echo 1000 > $dir/crlnumber
# cd $dir
export crlDP=
# For CRL support use uncomment these:
#crl=8021ARintermediate.crl.pem
#crlurl=www.htt-consult.com/pki/$crl
#export crlDP="URI:http://$crlurl"
export default_crl_days=30
export ocspIAI=
# For OCSP support use uncomment these:
#ocspurl=ocsp.htt-consult.com
#export ocspIAI="OCSP;URI:http://$ocspurl"
countryName="/C=US"
stateOrProvinceName="/ST=MI"
localityName="/L=Oak Park"
organizationName="/O=HTT Consulting"
organizationalUnitName="/OU=Devices"
#organizationalUnitName=
commonName="/CN=802.1AR CA"
DN=$countryName$stateOrProvinceName$localityName$organizationName
DN=$DN$organizationalUnitName$commonName
echo $DN
export subjectAltName=email:[email protected]
echo $subjectAltName
</sourcecode>
Create the file, $dir/openssl-8021ARintermediate.cnf from the
contents in Appendix A.3. Uncomment lines for crlDistributionPoints
and authorityInfoAccess if using CRLs or OSCP repectfully.
6.2. Create the 802.1AR Intermediate Certificate
Here are the openssl commands to create the 802.1AR Intermediate
certificate keypair, 802.1AR Intermediate certificate signed request
(CSR), and the 802.1AR Intermediate certificate. Included are
commands to view the file contents.
Moskowitz, et al. Expires February 10, 2021 [Page 12]
Internet-Draft PKI Guide August 2020
<sourcecode> file "intermediate_1ar_cert.sh"
# Create passworded keypair file
openssl genpkey -aes256 -algorithm ec\
-pkeyopt ec_paramgen_curve:prime256v1 \
-outform $format -pkeyopt ec_param_enc:named_curve\
-out $dir/private/8021ARintermediate.key.$format
chmod 400 $dir/private/8021ARintermediate.key.$format
openssl pkey -inform $format\
-in $dir/private/8021ARintermediate.key.$format -text -noout
# Create the CSR
openssl req -config $cadir/openssl-root.cnf\
-key $dir/private/8021ARintermediate.key.$format \
-keyform $format -outform $format -subj "$DN" -new -sha256\
-out $dir/csr/8021ARintermediate.csr.$format
openssl req -text -noout -verify -inform $format\
-in $dir/csr/8021ARintermediate.csr.$format
# Create 802.1AR Intermediate Certificate file
# The following does NOT work for DER
openssl rand -hex $sn > $dir/serial # hex 8 is minimum, 19 is maximum
# Note 'openssl ca' does not support DER format
openssl ca -config $cadir/openssl-root.cnf -days 3650\
-extensions v3_intermediate_ca -notext -md sha256\
-in $dir/csr/8021ARintermediate.csr.$format\
-out $dir/certs/8021ARintermediate.cert.pem
chmod 444 $dir/certs/8021ARintermediate.cert.$format
openssl verify -CAfile $cadir/certs/ca.cert.$format\
$dir/certs/8021ARintermediate.cert.$format
openssl x509 -noout -text\
-in $dir/certs/8021ARintermediate.cert.$format
# Create the certificate chain file
cat $dir/certs/8021ARintermediate.cert.$format\
$cadir/certs/ca.cert.$format > $dir/certs/ca-chain.cert.$format
chmod 444 $dir/certs/ca-chain.cert.$format
</sourcecode>
Moskowitz, et al. Expires February 10, 2021 [Page 13]
Internet-Draft PKI Guide August 2020
6.3. Create an 802.1AR iDevID Certificate
Here are the openssl commands to create a 802.1AR iDevID certificate
keypair, iDevID certificate signed request (CSR), and the iDevID
certificate. Included are commands to view the file contents.
<sourcecode> file "idevid-csr-cert.sh"
DevID=Wt1234
countryName=
stateOrProvinceName=
localityName=
organizationName="/O=HTT Consulting"
organizationalUnitName="/OU=Devices"
commonName=
serialNumber="/serialNumber=$DevID"
DN=$countryName$stateOrProvinceName$localityName
DN=$DN$organizationName$organizationalUnitName$commonName
DN=$DN$serialNumber
echo $DN
# hwType is OID for HTT Consulting, devices, sensor widgets
export hwType=1.3.6.1.4.1.6715.10.1
export hwSerialNum=01020304 # Some hex
export subjectAltName="otherName:1.3.6.1.5.5.7.8.4;SEQ:hmodname"
echo $hwType - $hwSerialNum
if [ ! -f $dir/private/$DevID.key.$format ]; then
openssl genpkey -algorithm ec -pkeyopt ec_paramgen_curve:prime256v1\
-pkeyopt ec_param_enc:named_curve\
-out $dir/private/$DevID.key.$format
chmod 400 $dir/private/$DevID.key.$format
fi
openssl pkey -in $dir/private/$DevID.key.$format -text -noout
openssl req -config $cfgdir/openssl-8021ARintermediate.cnf\
-key $dir/private/$DevID.key.$format \
-subj "$DN" -new -sha256 -out $dir/csr/$DevID.csr.$format
openssl req -text -noout -verify\
-in $dir/csr/$DevID.csr.$format
openssl asn1parse -i -in $dir/csr/$DevID.csr.pem
# offset of start of hardwareModuleName and use that in place of 189
openssl asn1parse -i -strparse 189 -in $dir/csr/$DevID.csr.pem
openssl rand -hex $sn > $dir/serial # hex 8 is minimum, 19 is maximum
# Note 'openssl ca' does not support DER format
openssl ca -config $cfgdir/openssl-8021ARintermediate.cnf -days 375\
Moskowitz, et al. Expires February 10, 2021 [Page 14]
Internet-Draft PKI Guide August 2020
-extensions 8021ar_idevid -notext -md sha256 \
-in $dir/csr/$DevID.csr.$format\
-out $dir/certs/$DevID.cert.$format
chmod 444 $dir/certs/$DevID.cert.$format
openssl verify -CAfile $dir/certs/ca-chain.cert.$format\
$dir/certs/$DevID.cert.$format
openssl x509 -noout -text -in $dir/certs/$DevID.cert.$format
openssl asn1parse -i -in $dir/certs/$DevID.cert.pem
# offset of start of hardwareModuleName and use that in place of 493
openssl asn1parse -i -strparse 493 -in $dir/certs/$DevID.cert.pem
</sourcecode>
7. Setting up a CRL for an Intermediate CA
This part provides CRL support to an Intermediate CA. In this memo
it applies to both Intermediate CAs. Set the crlDistributionPoints
as provided via the environment variables.
7.1. Create (or recreate) the CRL
It is simple to create the CRL. The CRL consists of the certificates
flagged with an R (Revoked) in index.txt:
<sourcecode> file "crl-creation.sh"
# Select which Intermediate level
intermediate=intermediate
#intermediate=8021ARintermediate
dir=$cadir/$intermediate
crl=$intermediate.crl.pem
# Create CRL file
openssl ca -config $dir/openssl-$intermediate.cnf \
-gencrl -out $dir/crl/$crl
chmod 444 $dir/crl/$crl
openssl crl -in $dir/crl/$crl -noout -text
</sourcecode>
7.2. Revoke a Certificate
Revoking a certificate is a two step process. First identify the
target certificate, examples are listed below. Revoke it then
publish a new CRL.
Moskowitz, et al. Expires February 10, 2021 [Page 15]
Internet-Draft PKI Guide August 2020
<sourcecode> file "revoke-step1.sh"
targetcert=fqdn
#targetcert=clientemail
#targetcert=DevID
openssl ca -config $dir/openssl-$intermediate.cnf\
-revoke $dir/certs/$targetcert.cert.$format
</sourcecode>
Recreate the CRL using Section 7.1.
8. Setting up OCSP for an Intermediate CA
This part provides OCSP support to an Intermediate CA. In this memo
it applies to both Intermediate CAs. Set the authorityInfoAccess as
provided via the environment variables.
8.1. Create the OCSP Certificate
OCSP needs a signing certificate. This certificate must be signed by
the CA that signed the certificate being checked. The steps to
create this certificate is the similar to a Server certificate for
the CA:
Moskowitz, et al. Expires February 10, 2021 [Page 16]
Internet-Draft PKI Guide August 2020
<sourcecode> file "ocsp-setup.sh"
# Select which Intermediate level
intermediate=intermediate
#intermediate=8021ARintermediate
# Optionally, password encrypt key pair
encryptkey=
#encryptkey=-aes256
# Create the key pair in Intermediate level $intermediate
cd $dir
openssl genpkey -algorithm ec -pkeyopt ec_paramgen_curve:prime256v1\
$encryptkey -pkeyopt ec_param_enc:named_curve\
-out $dir/private/$ocspurl.key.$format
chmod 400 $dir/private/$ocspurl.$format
openssl pkey -in $dir/private/$ocspurl.key.$format -text -noout
# Create CSR
commonName=
DN=$countryName$stateOrProvinceName$localityName
DN=$DN$organizationName$organizationalUnitName$commonName
echo $DN
export subjectAltName="DNS:$ocspurl, email:$emailaddr"
echo $subjectAltName
openssl req -config $dir/openssl-$intermediate.cnf\
-key $dir/private/$ocspurl.key.$format \
-subj "$DN" -new -sha256 -out $dir/csr/$ocspurl.csr.$format
openssl req -text -noout -verify -in $dir/csr/$ocspurl.csr.$format
# Create Certificate
openssl rand -hex $sn > $dir/serial # hex 8 is minimum, 19 is maximum
# Note 'openssl ca' does not support DER format
openssl ca -config $dir/openssl-$intermediate.cnf -days 375\
-extensions ocsp -notext -md sha256 \
-in $dir/csr/$ocspurl.csr.$format\
-out $dir/certs/$ocspurl.cert.$format
chmod 444 $dir/certs/$ocspurl.cert.$format
openssl verify -CAfile $dir/certs/ca-chain.cert.$format\
$dir/certs/$ocspurl.cert.$format
openssl x509 -noout -text -in $dir/certs/$ocspurl.cert.$format
</sourcecode>
Moskowitz, et al. Expires February 10, 2021 [Page 17]
Internet-Draft PKI Guide August 2020
8.2. Revoke a Certificate
Revoke the certificate as in Section 7.2. The OCSP responder SHOULD
detect the flag change in index.txt and, when queried respond
appropriately.
8.3. Testing OCSP with Openssl
OpenSSL provides a simple OCSP service that can be used to test the
OCSP certificate and revocation process (Note that this only reads
the index.txt to get the certificate status at startup).
In a terminal window, set variables dir and ocspurl (examples below),
then run the simple OCSP service:
<sourcecode> file "run-ocsp-server.sh"
dir=/root/ca/intermediate
ocspurl=ocsp.htt-consult.com
openssl ocsp -port 2560 -text -rmd sha256\
-index $dir/index.txt \
-CA $dir/certs/ca-chain.cert.pem \
-rkey $dir/private/$ocspurl.key.pem \
-rsigner $dir/certs/$ocspurl.cert.pem \
-nrequest 1
</sourcecode>
In another window, test out a certificate status with:
<sourcecode> file "test-ocsp-server.sh"
targetcert=fqdn
#targetcert=clientemail
#targetcert=DevID
openssl ocsp -CAfile $dir/certs/ca-chain.cert.pem \
-url http://127.0.0.1:2560 -resp_text -sha256\
-issuer $dir/certs/$intermediate.cert.pem \
-cert $dir/certs/$targetcert.cert.pem
</sourcecode>