为什么我收到超大记录TLS错误?

时间:2016-08-24 14:38:45

标签: ssl go tls1.2

我尝试使用go-xmpp连接到DuckDuckGo's XMPP services

以下是我的测试用例:

package main

import (
    "crypto/tls"
    "log"

    "github.com/mattn/go-xmpp"
)

const (
    svr = "dukgo.com"
    usr = "testtesttest"
    pwd = "test123"
)

func main() {
    xmpp.DefaultConfig = tls.Config{
        ServerName:         svr,
        InsecureSkipVerify: false,
    }

    options := xmpp.Options{
        Host:     svr,
        User:     usr,
        Password: pwd,
    }

    _, err := options.NewClient()
    if err != nil {
        log.Fatal(err)
    }
}

正在执行log.Fatal块并返回以下错误消息:

2016/08/24 16:32:27 tls: oversized record received with length 28012
exit status 1

谷歌搜索错误指向我在Docker中出现相同的错误,因此这并不完全有用。这个错误是什么意思?我该怎么做才能解决这个问题?

1 个答案:

答案 0 :(得分:5)

就像你使用的go-xmpp软件包的例子一样,它也需要tls的端口。

所以没有它会尝试连接到HTTP端点并给你这个错误。当端点仅支持具有未知CA证书的HTTP或HTTPS时,您将看到类似的错误。

请注意,您使用的软件包还支持无TLS双重检查DuckGo xmpp要求并更改您的代码以匹配它们。

像这样的其他帖子

实施例

https://github.com/mattn/go-xmpp/blob/master/_example/example.go

// Server has the port
var server = flag.String("server", "talk.google.com:443", "server")
var username = flag.String("username", "", "username")
var password = flag.String("password", "", "password")
var status = flag.String("status", "xa", "status")
var statusMessage = flag.String("status-msg", "I for one welcome our new codebot overlords.", "status message")
var notls = flag.Bool("notls", false, "No TLS")
var debug = flag.Bool("debug", false, "debug output")
var session = flag.Bool("session", false, "use server session")

// Omitted code

var talk *xmpp.Client
var err error
options := xmpp.Options{Host: *server,
    User:          *username,
    Password:      *password,
    NoTLS:         *notls,
    Debug:         *debug,
    Session:       *session,
    Status:        *status,
    StatusMessage: *statusMessage,
}

talk, err = options.NewClient()