Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
docker-py
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
docker-py
Commits
8393dbca
Kaydet (Commit)
8393dbca
authored
Tem 08, 2014
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Improved TLSConfig API to be less obscure / more pythonic. Also improved / amended docs
üst
db454f01
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
18 deletions
+45
-18
README.md
README.md
+25
-6
tls.py
docker/tls.py
+20
-12
No files found.
README.md
Dosyayı görüntüle @
8393dbca
...
...
@@ -355,31 +355,49 @@ http://docs.docker.com/articles/https/ first.*
client
=
docker
.
Client
(
base_url
=
'<https_url>'
,
tls
=
True
)
```
Equivalent CLI options:
`docker --tls ...`
If you want to use TLS but don't want to verify the server certificate
(for example when testing with a self-signed certificate):
```
python
tls_config
=
docker
.
tls
.
TLSConfig
(
verify
=
False
)
client
=
docker
.
Client
(
base_url
=
'<https_url>'
,
tls
=
tls_config
)
```
*
Authenticate server based on given CA
```
python
tls_config
=
docker
.
tls
.
TLSConfig
(
False
,
tls_verify
=
True
,
tls_ca_cert
=
'/path/to/ca.pem'
)
tls_config
=
docker
.
tls
.
TLSConfig
(
server_cacert
=
'/path/to/ca.pem'
)
client
=
docker
.
Client
(
base_url
=
'<https_url>'
,
tls
=
tls_config
)
```
Equivalent CLI options:
`docker --tlsverify --tlscacert /path/to/ca.pem ...`
*
Authenticate with client certificate, do not authenticate server
based on given CA
```
python
tls_config
=
docker
.
tls
.
TLSConfig
(
True
,
tls_cert
=
'/path/to/client-cert.pem'
,
tls_key
=
'/path/to/client-key.pem'
True
,
client_cert
=
(
'/path/to/client-cert.pem'
,
'/path/to/client-key.pem'
)
)
client
=
docker
.
Client
(
base_url
=
'<https_url>'
,
tls
=
tls_config
)
```
Equivalent CLI options:
`docker --tls --tlscert /path/to/client-cert.pem
--tlskey /path/to/client-key.pem ...`
*
Authenticate with client certificate, authenticate server based on given CA
```
python
tls_config
=
docker
.
tls
.
TLSConfig
(
False
,
tls_cert
=
'/path/to/client-cert.pem'
,
tls_key
=
'/path/to/client-key.pem'
,
tls_ca_
cert
=
'/path/to/ca.pem'
client_cert
=
(
'/path/to/client-cert.pem'
,
'/path/to/client-key.pem'
)
,
server_ca
cert
=
'/path/to/ca.pem'
)
client
=
docker
.
Client
(
base_url
=
'<https_url>'
,
tls
=
tls_config
)
```
Equivalent CLI options:
`docker --tlsverify --tlscert /path/to/client-cert.pem
--tlskey /path/to/client-key.pem --tlscacert /path/to/ca.pem ...`
\ No newline at end of file
docker/tls.py
Dosyayı görüntüle @
8393dbca
...
...
@@ -9,8 +9,8 @@ class TLSConfig(object):
verify
=
None
ssl_version
=
None
def
__init__
(
self
,
tls
,
tls_cert
=
None
,
tls_key
=
None
,
tls_
verify
=
None
,
tls_ca_cert
=
None
,
ssl_version
=
None
):
def
__init__
(
self
,
client_cert
=
None
,
server_cacert
=
None
,
verify
=
None
,
ssl_version
=
None
):
# Argument compatibility/mapping with
# http://docs.docker.com/examples/https/
# This diverges from the Docker CLI in that users can specify 'tls'
...
...
@@ -25,27 +25,35 @@ class TLSConfig(object):
# In either case, Alert the user when both are expected, but any are
# missing.
if
tls_cert
or
tls_key
:
if
client_cert
:
try
:
tls_cert
,
tls_key
=
client_cert
except
ValueError
:
raise
errors
.
TLSParameterError
(
'client_config must be a tuple of'
' (client certificate, key file)'
)
if
not
(
tls_cert
and
tls_key
)
or
(
not
os
.
path
.
isfile
(
tls_cert
)
or
not
os
.
path
.
isfile
(
tls_key
)):
raise
errors
.
TLSParameterError
(
'
Client certificate must provide certificate and key files
'
' through t
ls_cert and tls_key params respectively
'
'
Path to a certificate and key files must be provided
'
' through t
he client_config param
'
)
self
.
cert
=
(
tls_cert
,
tls_key
)
# Either set verify to True (public/default CA checks) or to the
# path of a CA Cert file.
if
tls_
verify
is
not
None
:
if
not
tls_ca_
cert
:
self
.
verify
=
tls_
verify
elif
os
.
path
.
isfile
(
tls_ca_
cert
):
if
not
tls_
verify
:
if
verify
is
not
None
:
if
not
server_ca
cert
:
self
.
verify
=
verify
elif
os
.
path
.
isfile
(
server_ca
cert
):
if
not
verify
:
raise
errors
.
TLSParameterError
(
'
tls_
verify can not be False when a CA cert is'
'verify can not be False when a CA cert is'
' provided.'
)
self
.
verify
=
tls_ca_
cert
self
.
verify
=
server_ca
cert
else
:
raise
errors
.
TLSParameterError
(
'Invalid CA certificate provided for `tls_ca_cert`.'
...
...
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