@@ -21,6 +21,8 @@ type QUICConfig = {
21
21
* Private key as a PEM string or Uint8Array buffer containing PEM formatted
22
22
* key. You can pass multiple keys. The number of keys must match the number
23
23
* of certs. Each key must be associated to the the corresponding cert chain.
24
+ *
25
+ * Currently multiple key and certificate chains is not supported.
24
26
*/
25
27
key ?: string | Array < string > | Uint8Array | Array < Uint8Array > ;
26
28
@@ -30,6 +32,8 @@ type QUICConfig = {
30
32
* certificate chain in subject to issuer order. Multiple certificate chains
31
33
* can be passed. The number of certificate chains must match the number of
32
34
* keys. Each certificate chain must be associated to the corresponding key.
35
+ *
36
+ * Currently multiple key and certificate chains is not supported.
33
37
*/
34
38
cert ?: string | Array < string > | Uint8Array | Array < Uint8Array > ;
35
39
@@ -43,19 +47,21 @@ type QUICConfig = {
43
47
* - rsa_pss_rsae_sha256
44
48
* - rsa_pss_rsae_sha384
45
49
* - rsa_pss_rsae_sha512
46
- * - rsa_pss_pss_sha256
47
- * - rsa_pss_pss_sha384
48
- * - rsa_pss_pss_sha512
49
50
* - ecdsa_secp256r1_sha256
50
51
* - ecdsa_secp384r1_sha384
51
52
* - ecdsa_secp521r1_sha512
52
53
* - ed25519
53
- * - ed448
54
54
*/
55
55
sigalgs ?: string ;
56
56
57
+ /**
58
+ * Verify the other peer.
59
+ * Clients by default set this to true.
60
+ * Servers by default set this to false.
61
+ */
57
62
verifyPeer : boolean ;
58
- logKeys : string | undefined ;
63
+
64
+ logKeys ?: string ;
59
65
grease : boolean ;
60
66
maxIdleTimeout : number ;
61
67
maxRecvUdpPayloadSize : number ;
@@ -70,29 +76,28 @@ type QUICConfig = {
70
76
enableEarlyData : boolean ;
71
77
} ;
72
78
79
+ /**
80
+ * BoringSSL does not support:
81
+ * - rsa_pss_pss_sha256
82
+ * - rsa_pss_pss_sha384
83
+ * - rsa_pss_pss_sha512
84
+ * - ed448
85
+ */
73
86
const sigalgs = [
74
87
'rsa_pkcs1_sha256' ,
75
88
'rsa_pkcs1_sha384' ,
76
89
'rsa_pkcs1_sha512' ,
77
90
'rsa_pss_rsae_sha256' ,
78
91
'rsa_pss_rsae_sha384' ,
79
92
'rsa_pss_rsae_sha512' ,
80
- 'rsa_pss_pss_sha256' ,
81
- 'rsa_pss_pss_sha384' ,
82
- 'rsa_pss_pss_sha512' ,
83
93
'ecdsa_secp256r1_sha256' ,
84
94
'ecdsa_secp384r1_sha384' ,
85
95
'ecdsa_secp521r1_sha512' ,
86
96
'ed25519' ,
87
- 'ed448' ,
88
97
] . join ( ':' ) ;
89
98
90
99
const clientDefault : QUICConfig = {
91
- ca : undefined ,
92
- key : undefined ,
93
- cert : undefined ,
94
100
sigalgs,
95
- logKeys : undefined ,
96
101
verifyPeer : true ,
97
102
grease : true ,
98
103
maxIdleTimeout : 5000 ,
@@ -104,16 +109,13 @@ const clientDefault: QUICConfig = {
104
109
initialMaxStreamsBidi : 100 ,
105
110
initialMaxStreamsUni : 100 ,
106
111
disableActiveMigration : true ,
112
+ // Test if this is needed
107
113
applicationProtos : [ 'http/0.9' ] ,
108
114
enableEarlyData : true ,
109
115
} ;
110
116
111
117
const serverDefault : QUICConfig = {
112
- ca : undefined ,
113
- key : undefined ,
114
- cert : undefined ,
115
118
sigalgs,
116
- logKeys : undefined ,
117
119
verifyPeer : false ,
118
120
grease : true ,
119
121
maxIdleTimeout : 5000 ,
@@ -125,6 +127,7 @@ const serverDefault: QUICConfig = {
125
127
initialMaxStreamsBidi : 100 ,
126
128
initialMaxStreamsUni : 100 ,
127
129
disableActiveMigration : true ,
130
+ // Test if this is needed
128
131
applicationProtos : [ 'http/0.9' ] ,
129
132
enableEarlyData : true ,
130
133
} ;
@@ -207,13 +210,21 @@ function buildQuicheConfig(config: QUICConfig): QuicheConfig {
207
210
}
208
211
certChainPEMBuffers = certChainPEMs . map ( ( c ) => textEncoder . encode ( c ) ) ;
209
212
}
210
- const quicheConfig : QuicheConfig = quiche . Config . withBoringSslCtx (
211
- config . verifyPeer ,
212
- caPEMBuffer ,
213
- keyPEMBuffers ,
214
- certChainPEMBuffers ,
215
- config . sigalgs ,
216
- ) ;
213
+ let quicheConfig : QuicheConfig ;
214
+ try {
215
+ quicheConfig = quiche . Config . withBoringSslCtx (
216
+ config . verifyPeer ,
217
+ caPEMBuffer ,
218
+ keyPEMBuffers ,
219
+ certChainPEMBuffers ,
220
+ config . sigalgs ,
221
+ ) ;
222
+ } catch ( e ) {
223
+ throw new errors . ErrorQUICConfig (
224
+ `Failed to build Quiche config with custom SSL context: ${ e . message } ` ,
225
+ { cause : e }
226
+ ) ;
227
+ }
217
228
if ( config . logKeys != null ) {
218
229
quicheConfig . logKeys ( ) ;
219
230
}
0 commit comments