elazarl / goproxy

An HTTP proxy library for Go
BSD 3-Clause "New" or "Revised" License
5.99k stars 1.09k forks source link

Improperly formatted DER-encoded message #182

Open Glavic opened 8 years ago

Glavic commented 8 years ago

In Firefox v48 I get following error while connecting to HTTPS website on which I use MITM:

An error occurred during a connection to wikipedia.org. security library: improperly formatted DER-encoded message. Error code: SEC_ERROR_BAD_DER

Script I use:

func main() {
    proxy := goproxy.NewProxyHttpServer()

    condition := goproxy.UrlMatches(regexp.MustCompile("^wikipedia.org:443"))

    proxy.OnRequest(condition).HandleConnect(goproxy.AlwaysMitm)
    proxy.OnResponse(condition).DoFunc(func(res *http.Response, ctx *goproxy.ProxyCtx) *http.Response {
        b, _ := ioutil.ReadAll(res.Body)
        res.Body = ioutil.NopCloser(bytes.NewBuffer(b))
        go DoStuff(b)
        return res
    })

    log.Fatal(http.ListenAndServe(":8081", proxy))
}

func DoStuff(b []byte) {
    fmt.Printf("Do something with byte len=%d\n", len(b))
}

What can be done?

Glavic commented 8 years ago

Issue 142 is probably the same?

alexio777 commented 7 years ago

Got same error.