Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client cert fix in release/0.50.0 #1097

Merged
merged 4 commits into from
Jan 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ambassador/ambassador/ir/irtlscontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,10 @@ def from_legacy(cls, ir: 'IR', name: str, rkey: str, location: str,
value = validation_ca.get(key, None)

if value:
new_args[key] = value
if key == 'secret':
new_args['ca_secret'] = value
else:
new_args[key] = value

if (('ca_secret' not in new_args) and
('cacert_chain_file' not in new_args)):
Expand Down
1 change: 0 additions & 1 deletion ambassador/tests/kat/abstract_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ def requirements(self):
yield ("url", Query(self.url("ambassador/v0/check_ready")))
yield ("url", Query(self.url("ambassador/v0/check_alive")))


@abstract_test
class ServiceType(Node):

Expand Down
150 changes: 150 additions & 0 deletions ambassador/tests/kat/test_ambassador.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import pytest
import os
import base64

from typing import ClassVar, Dict, Sequence, Tuple, Union

Expand Down Expand Up @@ -95,6 +96,155 @@ def requirements(self):
yield from (r for r in super().requirements() if r[0] == "url" and r[1].url.startswith("http://"))


class ClientCertificateAuthentication(AmbassadorTest):
presto_crt = """
-----BEGIN CERTIFICATE-----
MIIDYTCCAkkCCQCrK74a3GFhijANBgkqhkiG9w0BAQsFADBxMQswCQYDVQQGEwJV
UzELMAkGA1UECAwCTUExDzANBgNVBAcMBkJvc3RvbjERMA8GA1UECgwIRGF0YXdp
cmUxFDASBgNVBAsMC0VuZ2luZWVyaW5nMRswGQYDVQQDDB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1yOa2evA7165jd0qjKPO2X2FO41X8B
pAaKdLg2imh/p/cW7bgr3G6tGTFU1VGjyeLMDWD50evM62vzX8TnaUzdTGN1Nu36
rZ3bg+EKr8Eb25odZlJr2mf6KRx7Sr6sOSx6Q5TxRosrrftwKcz29pve0d8oCbdi
DROVVc5zAim3scfwupEBkC61vZJ38fiv0DCX9ZgkpLtFJQ9eLEPHGJPjyfewjSSy
/nNv/mRsbziCmCtwgpflTm89c+q3IhomA5axYAQcCCj9po5HUdrmIBJGLAMVy9by
FgdNthWAxvB4vfAyx9sCAwEAAaNTMFEwHQYDVR0OBBYEFGT9P/8pPxb7QRUxW/Wh
izd2sglKMB8GA1UdIwQYMBaAFGT9P/8pPxb7QRUxW/Whizd2sglKMA8GA1UdEwEB
/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAKsVOarsMZIxK9JKS0GTsgEsca8j
YaL85balnwAnpq2YR0cH2XowgKb3r3ufmTB4DsY/Q0iehCJy339Br65P1PJ0h/zf
dFNrvJ4ioX5LZw9bJ0AQND+YQ0E+MttZilOClsO9PBvmmPJuuaeaWoKjVfsN/Tc0
2qLU3ZU0z9nhXx6e9bqaFKIMcbqbVOgKjwWFil9dDn/CoJlaTS4IZ9NhqcS8X1wt
T2md/IKZhKJsp7VPFx59ehngEOjFhphswm1t8gAeq/P7JHZQyAPfXl3rd1RARnER
AJfULDOksXSEodSf+mGCkUhuod/h8LMGWLXzCgtHpJ2wZTp9kVVUkJvJjIU=
-----END CERTIFICATE-----
"""

def init(self):
self.target = HTTP()

def manifests(self) -> str:
return super().manifests() + """
---
apiVersion: v1
metadata:
name: client-cert-secret
data:
tls.crt: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUR1RENDQXFDZ0F3SUJBZ0lKQUowWDU3ZXlwQk5UTUEwR0NTcUdTSWIzRFFFQkN3VUFNSEV4Q3pBSkJnTlYKQkFZVEFsVlRNUXN3Q1FZRFZRUUlEQUpOUVRFUE1BMEdB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rM1JXVFdEMFpFTkxkSDBBcXMwZTFDSVdvR0ZWYi9ZaVlUSEFUCmwvWW03UUtCZ1FEcFYvSjRMakY5VzBlUlNXenFBaDN1TStCdzNNN2NEMUxnUlZ6ZWxGS2w2ZzRBMWNvdU8wbHAKalpkMkVMZDlzTHhBVENVeFhQZ0dDTjY0RVNZSi92ZUozUmJzMTMrU2xqdjRleTVKck1ieEhNRC9CU1ovY2VjaAp4aFNWNkJsMHVKb2tlMTRPMEJ3OHJzSUlxZTVZSUxqSlMwL2E2eTllSlJtaGZJVG9PZU5PTUE9PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo=
"""

def config(self):
yield self, self.format("""
---
apiVersion: ambassador/v0
kind: Module
ambassador_id: {self.ambassador_id}
name: tls
config:
server:
enabled: True
secret: client-cert-server-secret
client:
enabled: True
secret: client-cert-secret
cert_required: True
""")

yield self, self.format("""
---
apiVersion: ambassador/v0
kind: Mapping
name: {self.target.path.k8s}
prefix: /{self.name}/
service: {self.target.path.k8s}
""")

def scheme(self) -> str:
return "https"

def queries(self):
yield Query(self.url(self.name + "/"), insecure=True, client_crt=self.presto_crt, client_key=self.presto_key, client_cert_required=True, ca_cert=self.ca_cert)

yield Query(self.url(self.name + "/"), insecure=True, error="handshake failure")

def requirements(self):
for r in super().requirements():
query = r[1]
query.insecure = True
query.client_cert = self.presto_crt
query.client_key = self.presto_key
query.client_cert_required = True
query.ca_cert = self.ca_cert
yield (r[0], query)


class TLSOriginationSecret(AmbassadorTest):

def init(self):
Expand Down
48 changes: 48 additions & 0 deletions kat/kat/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"crypto/tls"
"crypto/x509"
"encoding/json"
"flag"
"fmt"
Expand Down Expand Up @@ -61,6 +62,37 @@ func rlimit() {

type Query map[string]interface{}

func (q Query) CACert() string {
val, ok := q["ca_cert"]
if ok {
return val.(string)
}
return ""
}

func (q Query) ClientCert() string {
val, ok := q["client_cert"]
if ok {
return val.(string)
}
return ""
}



func (q Query) ClientKey() string {
val, ok := q["client_key"]
if ok {
return val.(string)
}
return ""
}

func (q Query) ClientCertRequired() bool {
val, ok := q[""]
return ok && val.(bool)
}

func (q Query) Insecure() bool {
val, ok := q["insecure"]
return ok && val.(bool)
Expand Down Expand Up @@ -204,6 +236,22 @@ func main() {
IdleConnTimeout: 30 * time.Second,
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}

caCert := query.CACert()
if len(caCert) > 0 {

caCertPool := x509.NewCertPool()
caCertPool.AppendCertsFromPEM([]byte(caCert))

clientCert, err := tls.X509KeyPair([]byte(query.ClientCert()), []byte(query.ClientKey()))
if err != nil {
log.Fatal(err)
}

insecure_tr.TLSClientConfig.RootCAs = caCertPool
insecure_tr.TLSClientConfig.Certificates = []tls.Certificate{clientCert}
}

insecure_client := &http.Client{
Transport: insecure_tr,
Timeout: time.Duration(10 * time.Second),
Expand Down
15 changes: 14 additions & 1 deletion kat/kat/harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def ambassador_id(self):
class Query:

def __init__(self, url, expected=None, method="GET", headers=None, messages=None, insecure=False, skip=None,
xfail=None, phase=1, debug=False, sni=False, error=None):
xfail=None, phase=1, debug=False, sni=False, error=None, client_crt=None, client_key=None, client_cert_required=False, ca_cert=None):
self.method = method
self.url = url
self.headers = headers
Expand All @@ -268,6 +268,10 @@ def __init__(self, url, expected=None, method="GET", headers=None, messages=None
self.debug = debug
self.sni = sni
self.error = error
self.client_cert_required = client_cert_required
self.client_cert = client_crt
self.client_key = client_key
self.ca_cert = ca_cert

def as_json(self):
result = {
Expand All @@ -283,6 +287,15 @@ def as_json(self):
result["headers"] = self.headers
if self.messages is not None:
result["messages"] = self.messages
if self.client_cert is not None:
result["client_cert"] = self.client_cert
if self.client_key is not None:
result["client_key"] = self.client_key
if self.ca_cert is not None:
result["ca_cert"] = self.ca_cert
if self.client_cert_required:
result["client_cert_required"] = self.client_cert_required

return result


Expand Down