Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
37e8c170
Commit
37e8c170
authored
Jun 24, 2018
by
Hannes Hörl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not do noramlization of the fingerprint format
parent
7c27cd08
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
54 deletions
+8
-54
connection.go
pkg/cloudprovider/providers/vsphere/vclib/connection.go
+1
-29
connection_test.go
pkg/cloudprovider/providers/vsphere/vclib/connection_test.go
+7
-25
No files found.
pkg/cloudprovider/providers/vsphere/vclib/connection.go
View file @
37e8c170
...
...
@@ -17,7 +17,6 @@ limitations under the License.
package
vclib
import
(
"bytes"
"context"
"crypto/tls"
"encoding/pem"
...
...
@@ -25,7 +24,6 @@ import (
"net"
neturl
"net/url"
"sync"
"unicode"
"github.com/golang/glog"
"github.com/vmware/govmomi/session"
...
...
@@ -172,11 +170,7 @@ func (connection *VSphereConnection) NewClient(ctx context.Context) (*vim25.Clie
}
tpHost
:=
connection
.
Hostname
+
":"
+
connection
.
Port
tp
,
err
:=
normalizeThumbprint
(
connection
.
Thumbprint
)
if
err
!=
nil
{
return
nil
,
err
}
sc
.
SetThumbprint
(
tpHost
,
tp
)
sc
.
SetThumbprint
(
tpHost
,
connection
.
Thumbprint
)
client
,
err
:=
vim25
.
NewClient
(
ctx
,
sc
)
if
err
!=
nil
{
...
...
@@ -210,25 +204,3 @@ func (connection *VSphereConnection) UpdateCredentials(username string, password
connection
.
Username
=
username
connection
.
Password
=
password
}
func
normalizeThumbprint
(
original
string
)
(
string
,
error
)
{
buffer
:=
&
bytes
.
Buffer
{}
outIdx
:=
0
for
_
,
r
:=
range
original
{
if
outIdx
%
2
==
0
&&
outIdx
>
0
{
if
_
,
err
:=
buffer
.
WriteRune
(
':'
);
err
!=
nil
{
return
""
,
err
}
}
if
r
==
':'
{
continue
}
if
_
,
err
:=
buffer
.
WriteRune
(
unicode
.
ToUpper
(
r
));
err
!=
nil
{
return
""
,
err
}
outIdx
++
}
return
buffer
.
String
(),
nil
}
pkg/cloudprovider/providers/vsphere/vclib/connection_test.go
View file @
37e8c170
...
...
@@ -69,8 +69,13 @@ func createTestServer(
t
.
Fatal
(
"Expected server.TLS.Certificates not to be empty"
)
}
x509LeafCert
:=
server
.
TLS
.
Certificates
[
0
]
.
Certificate
[
0
]
tpBytes
:=
sha1
.
Sum
(
x509LeafCert
)
tpString
:=
fmt
.
Sprintf
(
"%x"
,
tpBytes
)
var
tpString
string
for
i
,
b
:=
range
sha1
.
Sum
(
x509LeafCert
)
{
if
i
>
0
{
tpString
+=
":"
}
tpString
+=
fmt
.
Sprintf
(
"%02X"
,
b
)
}
return
server
,
tpString
}
...
...
@@ -151,29 +156,6 @@ func TestWithValidThumbprint(t *testing.T) {
verifyConnectionWasMade
()
}
func
TestWithValidThumbprintAlternativeFormat
(
t
*
testing
.
T
)
{
handler
,
verifyConnectionWasMade
:=
getRequestVerifier
(
t
)
server
,
thumbprint
:=
createTestServer
(
t
,
fixtures
.
CaCertPath
,
fixtures
.
ServerCertPath
,
fixtures
.
ServerKeyPath
,
handler
)
server
.
StartTLS
()
u
:=
mustParseUrl
(
t
,
server
.
URL
)
// lowercase, remove the ':'
tpDifferentFormat
:=
strings
.
Replace
(
strings
.
ToLower
(
thumbprint
),
":"
,
""
,
-
1
)
connection
:=
&
vclib
.
VSphereConnection
{
Hostname
:
u
.
Hostname
(),
Port
:
u
.
Port
(),
Thumbprint
:
tpDifferentFormat
,
}
// Ignoring error here, because we only care about the TLS connection
connection
.
NewClient
(
context
.
Background
())
verifyConnectionWasMade
()
}
func
TestWithInvalidCaCertPath
(
t
*
testing
.
T
)
{
connection
:=
&
vclib
.
VSphereConnection
{
Hostname
:
"should-not-matter"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment