@@ -115,6 +115,31 @@ public class WolfSSLImplementSSLSession extends ExtendedSSLSession
115
115
* in resumption cases. */
116
116
private static final Object sesPtrLock = new Object ();
117
117
118
+ /**
119
+ * Stored SNI server names from original session, used during resumption
120
+ */
121
+ private List <SNIServerName > sniServerNames = null ;
122
+
123
+ /**
124
+ * Store SNI server names for this session for later resumption
125
+ * @param serverNames list of SNI server names to store
126
+ */
127
+ public synchronized void setSNIServerNames (List <SNIServerName > serverNames ) {
128
+ if (serverNames != null && !serverNames .isEmpty ()) {
129
+ this .sniServerNames = new ArrayList <>(serverNames );
130
+ WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
131
+ "Stored SNI server names for session resumption" );
132
+ }
133
+ }
134
+
135
+ /**
136
+ * Get stored SNI server names for this session
137
+ * @return list of stored SNI server names, may be null
138
+ */
139
+ public synchronized List <SNIServerName > getSNIServerNames () {
140
+ return this .sniServerNames ;
141
+ }
142
+
118
143
/**
119
144
* Create new WolfSSLImplementSSLSession
120
145
*
@@ -846,13 +871,27 @@ protected synchronized void setResume() {
846
871
* Update internally-stored session values.
847
872
*/
848
873
protected synchronized void updateStoredSessionValues () {
849
-
850
874
try {
851
875
this .protocol = this .ssl .getVersion ();
852
876
} catch (IllegalStateException | WolfSSLJNIException ex ) {
853
877
WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
854
878
"Not able to update stored WOLFSSL protocol" );
855
879
}
880
+
881
+ /* Also store SNI server names if not already set */
882
+ if (this .sniServerNames == null || this .sniServerNames .isEmpty ()) {
883
+ try {
884
+ List <SNIServerName > names = this .getRequestedServerNames ();
885
+ if (names != null && !names .isEmpty ()) {
886
+ this .sniServerNames = new ArrayList <>(names );
887
+ WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
888
+ "Extracted SNI server names from session" );
889
+ }
890
+ } catch (UnsupportedOperationException ex ) {
891
+ WolfSSLDebug .log (getClass (), WolfSSLDebug .INFO ,
892
+ "Error extracting SNI server names: " + ex .getMessage ());
893
+ }
894
+ }
856
895
}
857
896
858
897
/**
0 commit comments