Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(613)

Issue 70380043: code review 70380043: net/smtp: set ServerName in StartTLS, as now required b... (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 2 months ago by mra
Modified:
10 years, 2 months ago
Reviewers:
bradfitz
CC:
golang-codereviews, josharian, bradfitz
Visibility:
Public.

Description

net/smtp: set ServerName in StartTLS, as now required by crypto/tls the crypto/tls revision d3d43f270632 (CL 67010043, requiring ServerName or InsecureSkipVerify) breaks net/smtp, since it seems impossible to do SMTP via TLS anymore. i've tried to fix this by simply using a tls.Config with ServerName, instead of a nil *tls.Config. without this fix, doing SMTP with TLS results in error "tls: either ServerName or InsecureSkipVerify must be specified in the tls.Config". testing: the new method TestTlsClient(...) sets up a skeletal smtp server with tls capability, and test client injects a "fake" certificate allowing tls to work on localhost; thus, the modification to SendMail(...) enabling this. Fixes Issue 7437.

Patch Set 1 #

Patch Set 2 : diff -r 891e16653547 https://code.google.com/p/go #

Patch Set 3 : diff -r 891e16653547 https://code.google.com/p/go #

Patch Set 4 : diff -r d553518e7b1f https://code.google.com/p/go #

Patch Set 5 : diff -r d553518e7b1f https://code.google.com/p/go #

Total comments: 4

Patch Set 6 : diff -r 2750cd9fc49b https://code.google.com/p/go #

Patch Set 7 : diff -r 2750cd9fc49b https://code.google.com/p/go #

Total comments: 6

Patch Set 8 : diff -r 5414c904cc54 https://code.google.com/p/go #

Patch Set 9 : diff -r 5414c904cc54 https://code.google.com/p/go #

Patch Set 10 : diff -r 5414c904cc54 https://code.google.com/p/go #

Patch Set 11 : diff -r 5414c904cc54 https://code.google.com/p/go #

Total comments: 12

Patch Set 12 : diff -r 2708885f17a8 https://code.google.com/p/go #

Patch Set 13 : diff -r 2708885f17a8 https://code.google.com/p/go #

Patch Set 14 : diff -r 2708885f17a8 https://code.google.com/p/go #

Patch Set 15 : diff -r 2708885f17a8 https://code.google.com/p/go #

Unified diffs Side-by-side diffs Delta from patch set Stats (+151 lines, -1 line) Patch
M src/pkg/net/smtp/smtp.go View 1 2 3 4 5 8 9 2 chunks +7 lines, -1 line 0 comments Download
M src/pkg/net/smtp/smtp_test.go View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 chunks +144 lines, -0 lines 0 comments Download

Messages

Total messages: 22
mra
Hello golang-codereviews@googlegroups.com (cc: bradfitz@golang.org, golang-codereviews@googlegroups.com), I'd like you to review this change to https://code.google.com/p/go
10 years, 2 months ago (2014-03-01 12:13:36 UTC) #1
josharian
Thanks! Want to also add a test?
10 years, 2 months ago (2014-03-01 15:16:37 UTC) #2
mra
josh, i would love to, thanks, and i'll try to make similar to current net/smtp ...
10 years, 2 months ago (2014-03-01 15:31:53 UTC) #3
bradfitz
I've filed a bug for this so we don't forget to fix it before Go ...
10 years, 2 months ago (2014-03-01 17:36:29 UTC) #4
mra
Hello golang-codereviews@googlegroups.com, josharian@gmail.com (cc: bradfitz@golang.org, golang-codereviews@googlegroups.com), Please take another look.
10 years, 2 months ago (2014-03-01 22:58:02 UTC) #5
bradfitz
https://codereview.appspot.com/70380043/diff/80001/src/pkg/net/smtp/smtp.go File src/pkg/net/smtp/smtp.go (right): https://codereview.appspot.com/70380043/diff/80001/src/pkg/net/smtp/smtp.go#newcode275 src/pkg/net/smtp/smtp.go:275: func sendMail(addr string, a Auth, from string, to []string, ...
10 years, 2 months ago (2014-03-04 01:06:08 UTC) #6
mra
Hello golang-codereviews@googlegroups.com, josharian@gmail.com, bradfitz@golang.org (cc: golang-codereviews@googlegroups.com), Please take another look.
10 years, 2 months ago (2014-03-04 01:27:04 UTC) #7
mra
thanks for reviewing! i agree with all your comments, and i've done hg upload and ...
10 years, 2 months ago (2014-03-04 01:29:51 UTC) #8
josharian
Hi Mike, I haven't finished a full pass over this -- have to stop for ...
10 years, 2 months ago (2014-03-04 03:46:34 UTC) #9
mra
Hello golang-codereviews@googlegroups.com, josharian@gmail.com, bradfitz@golang.org (cc: golang-codereviews@googlegroups.com), Please take another look.
10 years, 2 months ago (2014-03-04 10:08:30 UTC) #10
mra
thanks for reviewing josh, i've made all your suggested changes and hg-uploaded/mailed just a moment ...
10 years, 2 months ago (2014-03-04 10:08:52 UTC) #11
mra
Hello golang-codereviews@googlegroups.com, josharian@gmail.com, bradfitz@golang.org (cc: golang-codereviews@googlegroups.com), Please take another look.
10 years, 2 months ago (2014-03-04 10:43:47 UTC) #12
mra
brad, josh, i thought about this a little bit more and just uploaded/mailed a slightly ...
10 years, 2 months ago (2014-03-04 10:50:37 UTC) #13
bradfitz
Please make the CL description's first line fit on one line, ~76 chars or less, ...
10 years, 2 months ago (2014-03-04 16:33:09 UTC) #14
josharian
https://codereview.appspot.com/70380043/diff/190001/src/pkg/net/smtp/smtp_test.go File src/pkg/net/smtp/smtp_test.go (right): https://codereview.appspot.com/70380043/diff/190001/src/pkg/net/smtp/smtp_test.go#newcode556 src/pkg/net/smtp/smtp_test.go:556: ln, err := net.Listen("tcp", fmt.Sprintf(":%d", tlsPort)) I worry that ...
10 years, 2 months ago (2014-03-04 16:34:54 UTC) #15
mra
Hello golang-codereviews@googlegroups.com, josharian@gmail.com, bradfitz@golang.org (cc: golang-codereviews@googlegroups.com), Please take another look.
10 years, 2 months ago (2014-03-04 21:31:33 UTC) #16
mra
brad and josh, i think i addressed all your points in my latest hg upload ...
10 years, 2 months ago (2014-03-04 21:32:31 UTC) #17
bradfitz
No need to not depend on fmt in a test. It's fine either way, but ...
10 years, 2 months ago (2014-03-04 21:36:43 UTC) #18
mra
Hello golang-codereviews@googlegroups.com, josharian@gmail.com, bradfitz@golang.org (cc: golang-codereviews@googlegroups.com), Please take another look.
10 years, 2 months ago (2014-03-04 21:41:36 UTC) #19
bradfitz
LGTM On Tue, Mar 4, 2014 at 1:41 PM, <mra@xoba.com> wrote: > Hello golang-codereviews@googlegroups.com, josharian@gmail.com, ...
10 years, 2 months ago (2014-03-04 21:43:16 UTC) #20
bradfitz
*** Submitted as https://code.google.com/p/go/source/detail?r=8f8ae5044f24 *** net/smtp: set ServerName in StartTLS, as now required by crypto/tls ...
10 years, 2 months ago (2014-03-04 21:43:32 UTC) #21
mra
10 years, 2 months ago (2014-03-04 21:45:19 UTC) #22
thanks brad, i changed sendf to send. i believe i've already electronically
signed the CLA form via http://golang.org/doc/contribute.html#copyright (
https://developers.google.com/open-source/cla/individual?csw=1), but if
folks can't find me in there i'd be glad to try again. best, mike


On Tue, Mar 4, 2014 at 4:36 PM, Brad Fitzpatrick <bradfitz@golang.org>wrote:

> No need to not depend on fmt in a test.  It's fine either way, but now you
> have a func named sendf that isn't printf-like. I'd remove the f now.
>
> LGTM otherwise.
>
>
>
> On Tue, Mar 4, 2014 at 1:31 PM, Mike Andrews <mra@xoba.com> wrote:
>
>> brad and josh, i think i addressed all your points in my latest hg upload
>> and mail, thanks for your patience and work in these code review rounds! i
>> also eliminated the dependency on fmt package and made a couple other
>> simplifications i hope are ok. best regards, mike.
>>
>>
>> On Tue, Mar 4, 2014 at 11:34 AM, <josharian@gmail.com> wrote:
>>
>>>
>>> https://codereview.appspot.com/70380043/diff/190001/src/
>>> pkg/net/smtp/smtp_test.go
>>> File src/pkg/net/smtp/smtp_test.go (right):
>>>
>>> https://codereview.appspot.com/70380043/diff/190001/src/
>>> pkg/net/smtp/smtp_test.go#newcode556
>>> src/pkg/net/smtp/smtp_test.go:556: ln, err := net.Listen("tcp",
>>> fmt.Sprintf(":%d", tlsPort))
>>> I worry that listening on a specific, hard-coded port will cause
>>> spurious failures. Better would be to have the OS select a free port for
>>> us and pass that in to sendMail. See e.g.
>>> http://golang.org/pkg/net/http/httptest.
>>>
>>> https://codereview.appspot.com/70380043/diff/190001/src/
>>> pkg/net/smtp/smtp_test.go#newcode558
>>> src/pkg/net/smtp/smtp_test.go:558: t.Fatalf("can't listen on port %d:
>>> %v", tlsPort, err)
>>> s/can't/failed to/ here and below
>>>
>>> https://codereview.appspot.com/70380043/diff/190001/src/
>>> pkg/net/smtp/smtp_test.go#newcode575
>>> src/pkg/net/smtp/smtp_test.go:575: ln.Close()
>>> defer ln.Close() right after checking listener err != nil
>>>
>>> https://codereview.appspot.com/70380043/diff/190001/src/
>>> pkg/net/smtp/smtp_test.go#newcode605
>>> src/pkg/net/smtp/smtp_test.go:605: }
>>> Slightly simpler config setup:
>>>
>>> keypair, err := tls.X509KeyPair([]byte(tlsCert), []byte(tlsKey))
>>> if err != nil {
>>>         return err
>>> }
>>> config := &tls.Config{Certificates: []tls.Certificate{keypair}}
>>>
>>> https://codereview.appspot.com/70380043/diff/190001/src/
>>> pkg/net/smtp/smtp_test.go#newcode608
>>> src/pkg/net/smtp/smtp_test.go:608: return serverHandleTLS(c)
>>> Should this switch have a default case that returns an error?
>>>
>>> https://codereview.appspot.com/70380043/diff/190001/src/
>>> pkg/net/smtp/smtp_test.go#newcode619
>>> src/pkg/net/smtp/smtp_test.go:619: case fmt.Sprintf("EHLO %s", tlsHost):
>>> I'd find this all a bit easier to read if tlsHost and tlsEmail were just
>>> inlined throughout this code, rather than calling fmt.Sprintf. (As a
>>> bonus, we wouldn't be re-evaluating fmt.Sprintf on every pass through.)
>>> This also matches the style in the other tests.
>>>
>>> https://codereview.appspot.com/70380043/diff/190001/src/
>>> pkg/net/smtp/smtp_test.go#newcode640
>>> src/pkg/net/smtp/smtp_test.go:640:
>>> testRootCAs.AppendCertsFromPEM([]byte(tlsCert))
>>> May as well move this parsing out of the func itself, and just close
>>> over testRootCAs.
>>>
>>> https://codereview.appspot.com/70380043/
>>>
>>
>>
>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b