Skip to content

Commit d19ed4f

Browse files
author
Phus Lu
committed
CA-208166: DockerMachine(golang clients) cannot connect XenServer host with ssl-legacy=false
Signed-off-by: Phus Lu <[email protected]>
1 parent bfc7452 commit d19ed4f

File tree

2 files changed

+136
-0
lines changed

2 files changed

+136
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
From 9d771b79c7bfa8db4a4a0075c72608f7d987b598 Mon Sep 17 00:00:00 2001
2+
From: Phus Lu <[email protected]>
3+
Date: Tue, 22 Mar 2016 02:56:41 +0800
4+
Subject: [PATCH] crypto/tls: add
5+
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256/TLS_RSA_WITH_AES_128_CBC_SHA256/TLS_RSA_WITH_AES_256_CBC_SHA256
6+
7+
---
8+
src/crypto/tls/cipher_suites.go | 20 ++++++++++++++++++++
9+
1 file changed, 20 insertions(+)
10+
11+
diff --git a/src/crypto/tls/cipher_suites.go b/src/crypto/tls/cipher_suites.go
12+
index e69f5f9..d544d4e 100644
13+
--- a/src/crypto/tls/cipher_suites.go
14+
+++ b/src/crypto/tls/cipher_suites.go
15+
@@ -11,6 +11,7 @@ import (
16+
"crypto/hmac"
17+
"crypto/rc4"
18+
"crypto/sha1"
19+
+ "crypto/sha256"
20+
"crypto/x509"
21+
"hash"
22+
)
23+
@@ -82,6 +83,7 @@ var cipherSuites = []*cipherSuite{
24+
{TLS_ECDHE_RSA_WITH_RC4_128_SHA, 16, 20, 0, ecdheRSAKA, suiteECDHE | suiteDefaultOff, cipherRC4, macSHA1, nil},
25+
{TLS_ECDHE_ECDSA_WITH_RC4_128_SHA, 16, 20, 0, ecdheECDSAKA, suiteECDHE | suiteECDSA | suiteDefaultOff, cipherRC4, macSHA1, nil},
26+
{TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, 16, 20, 16, ecdheRSAKA, suiteECDHE, cipherAES, macSHA1, nil},
27+
+ {TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256, 16, 32, 16, ecdheRSAKA, suiteECDHE, cipherAES, macSHA256, nil},
28+
{TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, 16, 20, 16, ecdheECDSAKA, suiteECDHE | suiteECDSA, cipherAES, macSHA1, nil},
29+
{TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, 32, 20, 16, ecdheRSAKA, suiteECDHE, cipherAES, macSHA1, nil},
30+
{TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, 32, 20, 16, ecdheECDSAKA, suiteECDHE | suiteECDSA, cipherAES, macSHA1, nil},
31+
@@ -90,6 +92,8 @@ var cipherSuites = []*cipherSuite{
32+
{TLS_RSA_WITH_RC4_128_SHA, 16, 20, 0, rsaKA, suiteDefaultOff, cipherRC4, macSHA1, nil},
33+
{TLS_RSA_WITH_AES_128_CBC_SHA, 16, 20, 16, rsaKA, 0, cipherAES, macSHA1, nil},
34+
{TLS_RSA_WITH_AES_256_CBC_SHA, 32, 20, 16, rsaKA, 0, cipherAES, macSHA1, nil},
35+
+ {TLS_RSA_WITH_AES_128_CBC_SHA256, 16, 32, 16, rsaKA, 0, cipherAES, macSHA256, nil},
36+
+ {TLS_RSA_WITH_AES_256_CBC_SHA256, 32, 32, 16, rsaKA, 0, cipherAES, macSHA256, nil},
37+
{TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA, 24, 20, 8, ecdheRSAKA, suiteECDHE, cipher3DES, macSHA1, nil},
38+
{TLS_RSA_WITH_3DES_EDE_CBC_SHA, 24, 20, 8, rsaKA, 0, cipher3DES, macSHA1, nil},
39+
}
40+
@@ -128,6 +132,19 @@ func macSHA1(version uint16, key []byte) macFunction {
41+
return tls10MAC{hmac.New(sha1.New, key)}
42+
}
43+
44+
+// macSHA256 returns a macFunction for the given protocol version.
45+
+func macSHA256(version uint16, key []byte) macFunction {
46+
+ if version == VersionSSL30 {
47+
+ mac := ssl30MAC{
48+
+ h: sha256.New(),
49+
+ key: make([]byte, len(key)),
50+
+ }
51+
+ copy(mac.key, key)
52+
+ return mac
53+
+ }
54+
+ return tls10MAC{hmac.New(sha256.New, key)}
55+
+}
56+
+
57+
type macFunction interface {
58+
Size() int
59+
MAC(digestBuf, seq, header, data []byte) []byte
60+
@@ -270,6 +287,8 @@ const (
61+
TLS_RSA_WITH_3DES_EDE_CBC_SHA uint16 = 0x000a
62+
TLS_RSA_WITH_AES_128_CBC_SHA uint16 = 0x002f
63+
TLS_RSA_WITH_AES_256_CBC_SHA uint16 = 0x0035
64+
+ TLS_RSA_WITH_AES_128_CBC_SHA256 uint16 = 0x003c
65+
+ TLS_RSA_WITH_AES_256_CBC_SHA256 uint16 = 0x003d
66+
TLS_RSA_WITH_AES_128_GCM_SHA256 uint16 = 0x009c
67+
TLS_RSA_WITH_AES_256_GCM_SHA384 uint16 = 0x009d
68+
TLS_ECDHE_ECDSA_WITH_RC4_128_SHA uint16 = 0xc007
69+
@@ -279,6 +298,7 @@ const (
70+
TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA uint16 = 0xc012
71+
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA uint16 = 0xc013
72+
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA uint16 = 0xc014
73+
+ TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 uint16 = 0xc027
74+
TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 uint16 = 0xc02f
75+
TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 uint16 = 0xc02b
76+
TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 uint16 = 0xc030
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
3+
export GITHUB_USER=${GITHUB_USER:-xenserver}
4+
export GITHUB_REPO=${GITHUB_REPO:-docker-machine-driver-xenserver}
5+
export GITHUB_COMMIT_ID=${TRAVIS_COMMIT:-${COMMIT_ID:-master}}
6+
export WORKING_DIR=/tmp/tmp.$(date "+%Y%m%d%H%M%S").${RANDOM:-$$}.${GITHUB_REPO}
7+
export GOROOT_BOOTSTRAP=${WORKING_DIR}/go1.6
8+
export GOROOT=${WORKING_DIR}/go
9+
export GOPATH=${WORKING_DIR}/gopath
10+
export PATH=$GOROOT/bin:$GOPATH/bin:$PATH
11+
12+
mkdir -p ${WORKING_DIR}
13+
14+
function build_go() {
15+
pushd ${WORKING_DIR}
16+
17+
curl -k https://storage.googleapis.com/golang/go1.6.linux-amd64.tar.gz | tar xz
18+
mv go go1.6
19+
20+
git clone --depth 50 --branch release-branch.go1.6 https://github.com/golang/go
21+
patch -d go -p1 < <(curl -k -L https://github.com/${GITHUB_USER}/${GITHUB_REPO}/raw/master/patches/TLS_RSA_WITH_AES_128_CBC_SHA256.patch)
22+
(cd go/src && bash ./make.bash)
23+
24+
go env
25+
go version
26+
27+
popd
28+
}
29+
30+
function build_repo() {
31+
pushd ${WORKING_DIR}
32+
33+
go get -v github.com/${GITHUB_USER}/${GITHUB_REPO}
34+
35+
popd
36+
}
37+
38+
function release_repo() {
39+
if [ "$TRAVIS_PULL_REQUEST" == "true" ]; then
40+
return
41+
fi
42+
43+
pushd ${WORKING_DIR}
44+
45+
if [ -d "${WORKSPACE}" ]; then
46+
local FILENAME=docker-machine-driver-xenserver_$(go env GOOS)-$(go env GOARCH)
47+
cp -rf $GOPATH/bin/docker-machine-driver-xenserver ${WORKSPACE}/${FILENAME}
48+
fi
49+
50+
popd
51+
}
52+
53+
function clean() {
54+
rm -rf $HOME/tmp.*.${GITHUB_REPO}
55+
}
56+
57+
build_go
58+
build_repo
59+
release_repo
60+
clean

0 commit comments

Comments
 (0)