@@ -21,6 +21,8 @@ type QUICConfig = {
2121 * Private key as a PEM string or Uint8Array buffer containing PEM formatted
2222 * key. You can pass multiple keys. The number of keys must match the number
2323 * of certs. Each key must be associated to the the corresponding cert chain.
24+ *
25+ * Currently multiple key and certificate chains is not supported.
2426 */
2527 key ?: string | Array < string > | Uint8Array | Array < Uint8Array > ;
2628
@@ -30,6 +32,8 @@ type QUICConfig = {
3032 * certificate chain in subject to issuer order. Multiple certificate chains
3133 * can be passed. The number of certificate chains must match the number of
3234 * keys. Each certificate chain must be associated to the corresponding key.
35+ *
36+ * Currently multiple key and certificate chains is not supported.
3337 */
3438 cert ?: string | Array < string > | Uint8Array | Array < Uint8Array > ;
3539
@@ -43,19 +47,21 @@ type QUICConfig = {
4347 * - rsa_pss_rsae_sha256
4448 * - rsa_pss_rsae_sha384
4549 * - rsa_pss_rsae_sha512
46- * - rsa_pss_pss_sha256
47- * - rsa_pss_pss_sha384
48- * - rsa_pss_pss_sha512
4950 * - ecdsa_secp256r1_sha256
5051 * - ecdsa_secp384r1_sha384
5152 * - ecdsa_secp521r1_sha512
5253 * - ed25519
53- * - ed448
5454 */
5555 sigalgs ?: string ;
5656
57+ /**
58+ * Verify the other peer.
59+ * Clients by default set this to true.
60+ * Servers by default set this to false.
61+ */
5762 verifyPeer : boolean ;
58- logKeys : string | undefined ;
63+
64+ logKeys ?: string ;
5965 grease : boolean ;
6066 maxIdleTimeout : number ;
6167 maxRecvUdpPayloadSize : number ;
@@ -70,29 +76,28 @@ type QUICConfig = {
7076 enableEarlyData : boolean ;
7177} ;
7278
79+ /**
80+ * BoringSSL does not support:
81+ * - rsa_pss_pss_sha256
82+ * - rsa_pss_pss_sha384
83+ * - rsa_pss_pss_sha512
84+ * - ed448
85+ */
7386const sigalgs = [
7487 'rsa_pkcs1_sha256' ,
7588 'rsa_pkcs1_sha384' ,
7689 'rsa_pkcs1_sha512' ,
7790 'rsa_pss_rsae_sha256' ,
7891 'rsa_pss_rsae_sha384' ,
7992 'rsa_pss_rsae_sha512' ,
80- 'rsa_pss_pss_sha256' ,
81- 'rsa_pss_pss_sha384' ,
82- 'rsa_pss_pss_sha512' ,
8393 'ecdsa_secp256r1_sha256' ,
8494 'ecdsa_secp384r1_sha384' ,
8595 'ecdsa_secp521r1_sha512' ,
8696 'ed25519' ,
87- 'ed448' ,
8897] . join ( ':' ) ;
8998
9099const clientDefault : QUICConfig = {
91- ca : undefined ,
92- key : undefined ,
93- cert : undefined ,
94100 sigalgs,
95- logKeys : undefined ,
96101 verifyPeer : true ,
97102 grease : true ,
98103 maxIdleTimeout : 5000 ,
@@ -104,16 +109,13 @@ const clientDefault: QUICConfig = {
104109 initialMaxStreamsBidi : 100 ,
105110 initialMaxStreamsUni : 100 ,
106111 disableActiveMigration : true ,
112+ // Test if this is needed
107113 applicationProtos : [ 'http/0.9' ] ,
108114 enableEarlyData : true ,
109115} ;
110116
111117const serverDefault : QUICConfig = {
112- ca : undefined ,
113- key : undefined ,
114- cert : undefined ,
115118 sigalgs,
116- logKeys : undefined ,
117119 verifyPeer : false ,
118120 grease : true ,
119121 maxIdleTimeout : 5000 ,
@@ -125,6 +127,7 @@ const serverDefault: QUICConfig = {
125127 initialMaxStreamsBidi : 100 ,
126128 initialMaxStreamsUni : 100 ,
127129 disableActiveMigration : true ,
130+ // Test if this is needed
128131 applicationProtos : [ 'http/0.9' ] ,
129132 enableEarlyData : true ,
130133} ;
@@ -207,13 +210,21 @@ function buildQuicheConfig(config: QUICConfig): QuicheConfig {
207210 }
208211 certChainPEMBuffers = certChainPEMs . map ( ( c ) => textEncoder . encode ( c ) ) ;
209212 }
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+ }
217228 if ( config . logKeys != null ) {
218229 quicheConfig . logKeys ( ) ;
219230 }
0 commit comments