233 } |
233 } |
234 |
234 |
235 Level level = Level.valueOf(am.level); |
235 Level level = Level.valueOf(am.level); |
236 Alert alert = Alert.valueOf(am.id); |
236 Alert alert = Alert.valueOf(am.id); |
237 if (alert == Alert.CLOSE_NOTIFY) { |
237 if (alert == Alert.CLOSE_NOTIFY) { |
238 if (tc.handshakeContext != null) { |
238 tc.isInputCloseNotified = true; |
|
239 tc.closeInbound(); |
|
240 |
|
241 if (tc.peerUserCanceled) { |
|
242 tc.closeOutbound(); |
|
243 } else if (tc.handshakeContext != null) { |
239 tc.fatal(Alert.UNEXPECTED_MESSAGE, |
244 tc.fatal(Alert.UNEXPECTED_MESSAGE, |
240 "Received close_notify during handshake"); |
245 "Received close_notify during handshake"); |
241 } |
246 } |
242 |
247 } else if (alert == Alert.USER_CANCELED) { |
243 tc.isInputCloseNotified = true; |
248 if (level == Level.WARNING) { |
244 tc.closeInbound(); |
249 tc.peerUserCanceled = true; |
|
250 } else { |
|
251 tc.fatal(alert, |
|
252 "Received fatal close_notify alert", true, null); |
|
253 } |
245 } else if ((level == Level.WARNING) && (alert != null)) { |
254 } else if ((level == Level.WARNING) && (alert != null)) { |
246 // Terminate the connection if an alert with a level of warning |
255 // Terminate the connection if an alert with a level of warning |
247 // is received during handshaking, except the no_certificate |
256 // is received during handshaking, except the no_certificate |
248 // warning. |
257 // warning. |
249 if (alert.handshakeOnly && (tc.handshakeContext != null)) { |
258 if (alert.handshakeOnly && (tc.handshakeContext != null)) { |