Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dex
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hdacloud
dex
Commits
81f15588
Unverified
Commit
81f15588
authored
6 years ago
by
Stephan Renatus
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #1392 from stevendanna/tls-configuration
Bump minimum TLS protocol to TLSv1.2
parents
5ae09420
59f8b02d
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
cmd/dex/serve.go
+28
-19
28 additions, 19 deletions
cmd/dex/serve.go
with
28 additions
and
19 deletions
cmd/dex/serve.go
+
28
−
19
View file @
81f15588
...
...
@@ -116,13 +116,19 @@ func serve(cmd *cobra.Command, args []string) error {
var
grpcOptions
[]
grpc
.
ServerOption
if
c
.
GRPC
.
TLSCert
!=
""
{
if
c
.
GRPC
.
TLSClientCA
!=
""
{
// Parse certificates from certificate file and key file for server.
cert
,
err
:=
tls
.
LoadX509KeyPair
(
c
.
GRPC
.
TLSCert
,
c
.
GRPC
.
TLSKey
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"invalid config: error parsing gRPC certificate file: %v"
,
err
)
}
// Parse certificates from certificate file and key file for server.
cert
,
err
:=
tls
.
LoadX509KeyPair
(
c
.
GRPC
.
TLSCert
,
c
.
GRPC
.
TLSKey
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"invalid config: error parsing gRPC certificate file: %v"
,
err
)
}
tlsConfig
:=
tls
.
Config
{
Certificates
:
[]
tls
.
Certificate
{
cert
},
MinVersion
:
tls
.
VersionTLS12
,
PreferServerCipherSuites
:
true
,
}
if
c
.
GRPC
.
TLSClientCA
!=
""
{
// Parse certificates from client CA file to a new CertPool.
cPool
:=
x509
.
NewCertPool
()
clientCert
,
err
:=
ioutil
.
ReadFile
(
c
.
GRPC
.
TLSClientCA
)
...
...
@@ -133,23 +139,17 @@ func serve(cmd *cobra.Command, args []string) error {
return
errors
.
New
(
"invalid config: failed to parse client CA"
)
}
tlsConfig
:=
tls
.
Config
{
Certificates
:
[]
tls
.
Certificate
{
cert
},
ClientAuth
:
tls
.
RequireAndVerifyClientCert
,
ClientCAs
:
cPool
,
}
tlsConfig
.
ClientAuth
=
tls
.
RequireAndVerifyClientCert
tlsConfig
.
ClientCAs
=
cPool
// Only add metrics if client auth is enabled
grpcOptions
=
append
(
grpcOptions
,
grpc
.
Creds
(
credentials
.
NewTLS
(
&
tlsConfig
)),
grpc
.
StreamInterceptor
(
grpcMetrics
.
StreamServerInterceptor
()),
grpc
.
UnaryInterceptor
(
grpcMetrics
.
UnaryServerInterceptor
()),
)
}
else
{
opt
,
err
:=
credentials
.
NewServerTLSFromFile
(
c
.
GRPC
.
TLSCert
,
c
.
GRPC
.
TLSKey
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"invalid config: load grpc certs: %v"
,
err
)
}
grpcOptions
=
append
(
grpcOptions
,
grpc
.
Creds
(
opt
))
}
grpcOptions
=
append
(
grpcOptions
,
grpc
.
Creds
(
credentials
.
NewTLS
(
&
tlsConfig
)))
}
s
,
err
:=
c
.
Storage
.
Config
.
Open
(
logger
)
...
...
@@ -275,9 +275,18 @@ func serve(cmd *cobra.Command, args []string) error {
}()
}
if
c
.
Web
.
HTTPS
!=
""
{
httpsSrv
:=
&
http
.
Server
{
Addr
:
c
.
Web
.
HTTPS
,
Handler
:
serv
,
TLSConfig
:
&
tls
.
Config
{
PreferServerCipherSuites
:
true
,
MinVersion
:
tls
.
VersionTLS12
,
},
}
logger
.
Infof
(
"listening (https) on %s"
,
c
.
Web
.
HTTPS
)
go
func
()
{
err
:
=
http
.
ListenAndServeTLS
(
c
.
Web
.
HTTPS
,
c
.
Web
.
TLSCert
,
c
.
Web
.
TLSKey
,
serv
)
err
=
http
sSrv
.
ListenAndServeTLS
(
c
.
Web
.
TLSCert
,
c
.
Web
.
TLSKey
)
errc
<-
fmt
.
Errorf
(
"listening on %s failed: %v"
,
c
.
Web
.
HTTPS
,
err
)
}()
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment