-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathglue_openssl.go
67 lines (58 loc) · 1.44 KB
/
glue_openssl.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// +build openssl
package main
import (
"log"
"net"
"github.com/spacemonkeygo/openssl"
)
/*
#cgo CFLAGS: -Wno-deprecated-declarations -std=c99 -D_POSIX_C_SOURCE=200809L
#include "goglue.h"
*/
import "C"
//export GlueStartSslCtrl
func GlueStartSslCtrl(ctx *C.client_ctx) {
clientCtx := GetDracCtx(ctx)
//tlsconfig := &tls.Config{
// InsecureSkipVerify: true,
//}
cipherCtx, _ := openssl.NewCtxWithVersion(openssl.SSLv3)
tlsConn, err := openssl.Client(clientCtx.ctrlSocket, cipherCtx)
if err != nil {
log.Printf("err: %v\n", err)
return
}
//tlsConn := tls.Client(clientCtx.ctrlSocket, tlsconfig)
//log.Printf("starting tls\n")
err = tlsConn.Handshake()
if err != nil {
log.Printf("err: %v\n", err)
return
}
//log.Printf("started tls\n")
ctrlSocket := net.Conn(tlsConn)
clientCtx.ctrlSocket = ctrlSocket
}
//export GlueStartSslVideo
func GlueStartSslVideo(ctx *C.client_ctx) {
clientCtx := GetDracCtx(ctx)
//tlsconfig := &tls.Config{
// InsecureSkipVerify: true,
//}
cipherCtx, _ := openssl.NewCtxWithVersion(openssl.SSLv3)
tlsConn, err := openssl.Client(clientCtx.videoSocket, cipherCtx)
if err != nil {
log.Printf("err: %v\n", err)
return
}
//tlsConn := tls.Client(clientCtx.videoSocket, tlsconfig)
//log.Printf("starting tls\n")
err = tlsConn.Handshake()
if err != nil {
log.Printf("err: %v\n", err)
return
}
//log.Printf("started tls\n")
videoSocket := net.Conn(tlsConn)
clientCtx.videoSocket = videoSocket
}