LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2010 The Go Authors. All rights reserved. | 1 // Copyright 2010 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // TLS low level connection and record layer | 5 // TLS low level connection and record layer |
6 | 6 |
7 package tls | 7 package tls |
8 | 8 |
9 import ( | 9 import ( |
10 "bytes" | 10 "bytes" |
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
597 | 597 |
598 if b != nil { | 598 if b != nil { |
599 c.in.freeBlock(b) | 599 c.in.freeBlock(b) |
600 } | 600 } |
601 return c.error() | 601 return c.error() |
602 } | 602 } |
603 | 603 |
604 // sendAlert sends a TLS alert message. | 604 // sendAlert sends a TLS alert message. |
605 // c.out.Mutex <= L. | 605 // c.out.Mutex <= L. |
606 func (c *Conn) sendAlertLocked(err alert) error { | 606 func (c *Conn) sendAlertLocked(err alert) error { |
607 » c.tmp[0] = alertLevelError | 607 » switch err { |
608 » if err == alertNoRenegotiation { | 608 » case alertNoRenegotiation, alertCloseNotify: |
609 c.tmp[0] = alertLevelWarning | 609 c.tmp[0] = alertLevelWarning |
| 610 default: |
| 611 c.tmp[0] = alertLevelError |
610 } | 612 } |
611 c.tmp[1] = byte(err) | 613 c.tmp[1] = byte(err) |
612 c.writeRecord(recordTypeAlert, c.tmp[0:2]) | 614 c.writeRecord(recordTypeAlert, c.tmp[0:2]) |
613 // closeNotify is a special case in that it isn't an error: | 615 // closeNotify is a special case in that it isn't an error: |
614 if err != alertCloseNotify { | 616 if err != alertCloseNotify { |
615 return c.setError(&net.OpError{Op: "local error", Err: err}) | 617 return c.setError(&net.OpError{Op: "local error", Err: err}) |
616 } | 618 } |
617 return nil | 619 return nil |
618 } | 620 } |
619 | 621 |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
858 c.handshakeMutex.Lock() | 860 c.handshakeMutex.Lock() |
859 defer c.handshakeMutex.Unlock() | 861 defer c.handshakeMutex.Unlock() |
860 if !c.isClient { | 862 if !c.isClient { |
861 return errors.New("VerifyHostname called on TLS server connectio
n") | 863 return errors.New("VerifyHostname called on TLS server connectio
n") |
862 } | 864 } |
863 if !c.handshakeComplete { | 865 if !c.handshakeComplete { |
864 return errors.New("TLS handshake has not yet been performed") | 866 return errors.New("TLS handshake has not yet been performed") |
865 } | 867 } |
866 return c.peerCertificates[0].VerifyHostname(host) | 868 return c.peerCertificates[0].VerifyHostname(host) |
867 } | 869 } |
LEFT | RIGHT |