2323
2424#include " P_QUICNetVConnection_quiche.h"
2525#include " P_QUICPacketHandler_quiche.h"
26+ #include " QUICMultiCertConfigLoader.h"
2627#include " quic/QUICStream_quiche.h"
28+ #include " quic/QUICGlobals.h"
2729#include < quiche.h>
2830
2931static constexpr ink_hrtime WRITE_READY_INTERVAL = HRTIME_MSECONDS(2 );
@@ -46,7 +48,7 @@ QUICNetVConnection::init(QUICVersion version, QUICConnectionId peer_cid, QUICCon
4648void
4749QUICNetVConnection::init (QUICVersion version, QUICConnectionId peer_cid, QUICConnectionId original_cid, QUICConnectionId first_cid,
4850 QUICConnectionId retry_cid, UDPConnection *udp_con, quiche_conn *quiche_con,
49- QUICPacketHandler *packet_handler, QUICConnectionTable *ctable)
51+ QUICPacketHandler *packet_handler, QUICConnectionTable *ctable, SSL *ssl )
5052{
5153 SET_HANDLER ((NetVConnHandler)&QUICNetVConnection::acceptEvent);
5254 this ->_udp_con = udp_con;
@@ -61,6 +63,10 @@ QUICNetVConnection::init(QUICVersion version, QUICConnectionId peer_cid, QUICCon
6163 this ->_ctable ->insert (this ->_quic_connection_id , this );
6264 this ->_ctable ->insert (this ->_original_quic_connection_id , this );
6365 }
66+
67+ this ->_ssl = ssl;
68+ SSL_set_ex_data (ssl, QUIC::ssl_quic_qc_index, static_cast <QUICConnection *>(this ));
69+ this ->_bindSSLObject ();
6470}
6571
6672void
@@ -114,6 +120,7 @@ QUICNetVConnection::free(EThread *t)
114120 this ->_context ->trigger (QUICContext::CallbackEvent::CONNECTION_CLOSE);
115121 ALPNSupport::clear ();
116122 TLSBasicSupport::clear ();
123+ TLSCertSwitchSupport::_clear ();
117124
118125 this ->_packet_handler ->close_connection (this );
119126 this ->_packet_handler = nullptr ;
@@ -489,6 +496,32 @@ QUICNetVConnection::load_buffer_and_write(int64_t towrite, MIOBufferAccessor &bu
489496 return 0 ;
490497}
491498
499+ bool
500+ QUICNetVConnection::getSSLHandShakeComplete () const
501+ {
502+ return quiche_conn_is_established (this ->_quiche_con );
503+ }
504+
505+ void
506+ QUICNetVConnection::_bindSSLObject ()
507+ {
508+ TLSBasicSupport::bind (this ->_ssl , this );
509+ ALPNSupport::bind (this ->_ssl , this );
510+ TLSSessionResumptionSupport::bind (this ->_ssl , this );
511+ TLSSNISupport::bind (this ->_ssl , this );
512+ TLSCertSwitchSupport::bind (this ->_ssl , this );
513+ }
514+
515+ void
516+ QUICNetVConnection::_unbindSSLObject ()
517+ {
518+ TLSBasicSupport::unbind (this ->_ssl );
519+ ALPNSupport::unbind (this ->_ssl );
520+ TLSSessionResumptionSupport::unbind (this ->_ssl );
521+ TLSSNISupport::unbind (this ->_ssl );
522+ TLSCertSwitchSupport::unbind (this ->_ssl );
523+ }
524+
492525void
493526QUICNetVConnection::_schedule_packet_write_ready (bool delay)
494527{
@@ -632,14 +665,79 @@ QUICNetVConnection::protocol_contains(std::string_view tag) const
632665 return " " ;
633666}
634667
668+ const char *
669+ QUICNetVConnection::get_server_name () const
670+ {
671+ return get_sni_server_name ();
672+ }
673+
674+ bool
675+ QUICNetVConnection::support_sni () const
676+ {
677+ return true ;
678+ }
679+
635680SSL *
636681QUICNetVConnection::_get_ssl_object () const
637682{
638- return nullptr ;
683+ return this -> _ssl ;
639684}
640685
641686ssl_curve_id
642687QUICNetVConnection::_get_tls_curve () const
643688{
644- return 0 ;
689+ if (getSSLSessionCacheHit ()) {
690+ return getSSLCurveNID ();
691+ } else {
692+ return SSLGetCurveNID (this ->_ssl );
693+ }
694+ }
695+
696+ void
697+ QUICNetVConnection::_fire_ssl_servername_event ()
698+ {
699+ }
700+
701+ const IpEndpoint &
702+ QUICNetVConnection::_getLocalEndpoint ()
703+ {
704+ return this ->local_addr ;
705+ }
706+
707+ bool
708+ QUICNetVConnection::_isTryingRenegotiation () const
709+ {
710+ // Renegotiation is not allowed on QUIC (TLS 1.3) connections.
711+ // If handshake is completed when this function is called, that should be unallowed attempt of renegotiation.
712+ return this ->getSSLHandShakeComplete ();
713+ }
714+
715+ shared_SSL_CTX
716+ QUICNetVConnection::_lookupContextByName (const std::string &servername, SSLCertContextType ctxType)
717+ {
718+ shared_SSL_CTX ctx = nullptr ;
719+ QUICCertConfig::scoped_config lookup;
720+ SSLCertContext *cc = lookup->find (servername, ctxType);
721+
722+ if (cc && cc->getCtx ()) {
723+ ctx = cc->getCtx ();
724+ }
725+
726+ return ctx;
727+ }
728+
729+ shared_SSL_CTX
730+ QUICNetVConnection::_lookupContextByIP ()
731+ {
732+ shared_SSL_CTX ctx = nullptr ;
733+ QUICCertConfig::scoped_config lookup;
734+ QUICFiveTuple five_tuple = this ->five_tuple ();
735+ IpEndpoint ip = five_tuple.destination ();
736+ SSLCertContext *cc = lookup->find (ip);
737+
738+ if (cc && cc->getCtx ()) {
739+ ctx = cc->getCtx ();
740+ }
741+
742+ return ctx;
645743}
0 commit comments