Fix certificat domain check in case of SRV
This commit is contained in:
parent
476e0d7ddb
commit
72135514fc
|
|
@ -26,10 +26,10 @@ const (
|
||||||
TypeAdHocNoteWarning = "warn"
|
TypeAdHocNoteWarning = "warn"
|
||||||
TypeAdHocNoteError = "error"
|
TypeAdHocNoteError = "error"
|
||||||
|
|
||||||
TypeAdHocFieldListMulti = "list-multi"
|
TypeAdHocFieldListMulti = "list-multi"
|
||||||
TypeAdHocFieldListSingle = "list-single"
|
TypeAdHocFieldListSingle = "list-single"
|
||||||
TypeAdHocFieldTextSingle = "text-single"
|
TypeAdHocFieldTextSingle = "text-single"
|
||||||
TypeAdHocFieldJidSingle = "jid-single"
|
TypeAdHocFieldJidSingle = "jid-single"
|
||||||
TypeAdHocFieldTextPrivate = "text-private"
|
TypeAdHocFieldTextPrivate = "text-private"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,7 @@ func startTLS(stream *Stream, config *ClientConfig) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
tlsConfig := tls.Config{InsecureSkipVerify: config.InsecureSkipVerify, ServerName: stream.connDomain}
|
tlsConfig := tls.Config{InsecureSkipVerify: config.InsecureSkipVerify, ServerName: stream.config.ConnectionDomain}
|
||||||
return stream.UpgradeTLS(&tlsConfig)
|
return stream.UpgradeTLS(&tlsConfig)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,9 @@ type StreamConfig struct {
|
||||||
// are either sent to the server or delivered to the application. It also
|
// are either sent to the server or delivered to the application. It also
|
||||||
// causes incoming stanzas to be XML-parsed a second time.
|
// causes incoming stanzas to be XML-parsed a second time.
|
||||||
LogStanzas bool
|
LogStanzas bool
|
||||||
|
|
||||||
|
// The dommain connection for certificat validation.
|
||||||
|
ConnectionDomain string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Stream struct {
|
type Stream struct {
|
||||||
|
|
@ -25,7 +28,6 @@ type Stream struct {
|
||||||
config *StreamConfig
|
config *StreamConfig
|
||||||
stanzaBuf string
|
stanzaBuf string
|
||||||
incomingNamespace nsMap
|
incomingNamespace nsMap
|
||||||
connDomain string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a XML stream connection. A Steam is used by an XMPP instance to
|
// Create a XML stream connection. A Steam is used by an XMPP instance to
|
||||||
|
|
@ -43,7 +45,10 @@ func NewStream(addr string, config *StreamConfig) (*Stream, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
stream := &Stream{conn: conn, dec: xml.NewDecoder(conn), config: config, connDomain: strings.SplitN(addr, ":", 2)[0]}
|
stream := &Stream{conn: conn, dec: xml.NewDecoder(conn), config: config}
|
||||||
|
if config.ConnectionDomain == "" {
|
||||||
|
config.ConnectionDomain = strings.SplitN(addr, ":", 2)[0]
|
||||||
|
}
|
||||||
|
|
||||||
if err := stream.send([]byte("<?xml version='1.0' encoding='utf-8'?>")); err != nil {
|
if err := stream.send([]byte("<?xml version='1.0' encoding='utf-8'?>")); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue