A
A
Alexey Akulovich2015-03-28 14:57:05
go
Alexey Akulovich, 2015-03-28 14:57:05

Golang, HTTPS requests to MS servers (SSL renegotiation). Does anyone have any successful experience?

Faced with an unpleasant feature that in the standard go library, support for ssl renegotiation was somewhat bypassed. A certain patch eventually comes in the delivery, but it's of little use.
Requests to https://s.notify.live.net/*** can be successfully sent using php curl (CAINFO, SSLCERT and SSLKEY are fine), but so far it hasn't been sent through go. I tried a lot of solutions, http/tls forks, all kinds of http2, go-curl, etc... At best, instead of "local error: no renegotiation" I get a 413 error.
Tried go 1.3 and 1.4.
Thanks in advance for any good advice.
PS Working version via github.com/andelf/go-curl (may be useful to someone):
(go1.4.2 linux/amd64; libcurl/7.32.0 OpenSSL/1.0.1e zlib/1.2.8 libidn/1.28 librtmp/2.3)

package main

import (
    curl "github.com/andelf/go-curl"
)

func main() {
    url  := `https://s.notify.live.net...`
    body := `<?xml version="1.0" encoding="utf-8"?>...`

    easy := curl.EasyInit()
    defer easy.Cleanup()
    if easy != nil {
        easy.Setopt(curl.OPT_URL, url)
        easy.Setopt(curl.OPT_POST, true)
        easy.Setopt(curl.OPT_VERBOSE, true)

        easy.Setopt(curl.OPT_SSLCERT, `cert/ssl.crt`)
        easy.Setopt(curl.OPT_SSLKEY,  `cert/ssl.key`)
        easy.Setopt(curl.OPT_CAINFO,  `cert/gd_bundle-g2-g1.crt`)
        easy.Setopt(curl.OPT_SSL_VERIFYHOST, 2)
        easy.Setopt(curl.OPT_SSL_VERIFYPEER, 1)
        easy.Setopt(curl.OPT_HTTPHEADER, []string{
            "Content-Type: text/xml",
            "X-NotificationClass: 2",
            "X-WindowsPhone-Target: toast",
        })

        easy.Setopt(curl.OPT_POSTFIELDS, body)
        easy.Perform()
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question