Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
key-storage-agent
Manage
Activity
Members
Labels
Plan
Issues
2
Issue boards
Milestones
Wiki
Code
Merge requests
2
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Code
key-storage-agent
Compare revisions
master to 1-loadbalancing
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
code/key-storage-agent
Select target project
No results found
1-loadbalancing
Select Git revision
Swap
Target
code/key-storage-agent
Select target project
code/key-storage-agent
1 result
master
Select Git revision
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (1)
tls changes
· cb1d6a09
Olgun Cengiz
authored
4 years ago
cb1d6a09
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Gopkg.toml
+5
-1
5 additions, 1 deletion
Gopkg.toml
config/configs.go
+7
-0
7 additions, 0 deletions
config/configs.go
server/server.go
+39
-37
39 additions, 37 deletions
server/server.go
utils/utils.go
+4
-3
4 additions, 3 deletions
utils/utils.go
with
55 additions
and
41 deletions
Gopkg.toml
View file @
cb1d6a09
[[constraint]]
[[constraint]]
branch
=
"
master
"
branch
=
"
1-loadbalancing
"
name
=
"code.vereign.com/code/viam-apis"
name
=
"code.vereign.com/code/viam-apis"
[[override]]
branch
=
"1-loadbalancing"
name
=
"code.vereign.com/billing-and-federation/apis"
[[override]]
[[override]]
name
=
"github.com/hashicorp/go-retryablehttp"
name
=
"github.com/hashicorp/go-retryablehttp"
version
=
"
=
v
0.5
.
4
"
version
=
"
=
v
0.5
.
4
"
...
...
This diff is collapsed.
Click to expand it.
config/configs.go
View file @
cb1d6a09
...
@@ -29,6 +29,7 @@ var VereignCaKeyPEM []byte
...
@@ -29,6 +29,7 @@ var VereignCaKeyPEM []byte
var
ReplaceKey
bool
var
ReplaceKey
bool
var
MaxMessageSize
int
var
MaxMessageSize
int
var
UseTLS
bool
var
GrpcListenAddress
string
var
GrpcListenAddress
string
var
RestListenAddress
string
var
RestListenAddress
string
...
@@ -55,6 +56,7 @@ func SetConfigValues(configFile, etcdURL string) {
...
@@ -55,6 +56,7 @@ func SetConfigValues(configFile, etcdURL string) {
viper
.
SetDefault
(
"viamSession"
,
"viam-session"
)
viper
.
SetDefault
(
"viamSession"
,
"viam-session"
)
viper
.
SetDefault
(
"maxMessageSize"
,
64
)
viper
.
SetDefault
(
"maxMessageSize"
,
64
)
viper
.
SetDefault
(
"useTls"
,
1
)
// Certification Related
// Certification Related
// File System Defaults
// File System Defaults
...
@@ -143,6 +145,11 @@ func SetConfigValues(configFile, etcdURL string) {
...
@@ -143,6 +145,11 @@ func SetConfigValues(configFile, etcdURL string) {
SystemAuth
.
Session
=
viper
.
GetString
(
"viamSession"
)
SystemAuth
.
Session
=
viper
.
GetString
(
"viamSession"
)
MaxMessageSize
=
viper
.
GetInt
(
"maxMessageSize"
)
MaxMessageSize
=
viper
.
GetInt
(
"maxMessageSize"
)
if
viper
.
GetInt
(
"useTls"
)
==
0
{
UseTLS
=
false
}
else
{
UseTLS
=
true
}
PrometeusListenAddress
=
viper
.
GetString
(
"prometeusListenAddress"
)
PrometeusListenAddress
=
viper
.
GetString
(
"prometeusListenAddress"
)
...
...
This diff is collapsed.
Click to expand it.
server/server.go
View file @
cb1d6a09
...
@@ -155,10 +155,6 @@ func createQueryTime(funcName string) prometheus.Summary {
...
@@ -155,10 +155,6 @@ func createQueryTime(funcName string) prometheus.Summary {
}
}
func
StartGRPCServer
(
address
string
,
certPEM
,
privateKeyPEM
,
caCertPEM
,
vereignCertPEM
,
vereignPrivateKeyPEM
[]
byte
,
dataStorageAddress
string
,
maxMessageSize
int
)
error
{
func
StartGRPCServer
(
address
string
,
certPEM
,
privateKeyPEM
,
caCertPEM
,
vereignCertPEM
,
vereignPrivateKeyPEM
[]
byte
,
dataStorageAddress
string
,
maxMessageSize
int
)
error
{
pkgCertPEM
=
certPEM
pkgKeyPEM
=
privateKeyPEM
pkgCaCertPEM
=
caCertPEM
// create a listener on TCP port
// create a listener on TCP port
lis
,
err
:=
net
.
Listen
(
"tcp"
,
address
)
lis
,
err
:=
net
.
Listen
(
"tcp"
,
address
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -166,6 +162,45 @@ func StartGRPCServer(address string, certPEM, privateKeyPEM, caCertPEM, vereignC
...
@@ -166,6 +162,45 @@ func StartGRPCServer(address string, certPEM, privateKeyPEM, caCertPEM, vereignC
return
fmt
.
Errorf
(
"failed to listen: %v"
,
err
)
return
fmt
.
Errorf
(
"failed to listen: %v"
,
err
)
}
}
pkgCertPEM
=
certPEM
pkgKeyPEM
=
privateKeyPEM
pkgCaCertPEM
=
caCertPEM
opts
:=
[]
grpc
.
ServerOption
{}
opts
=
append
(
opts
,
grpc
.
UnaryInterceptor
(
unaryInterceptor
),
grpc
.
MaxRecvMsgSize
(
config
.
MaxMessageSize
*
1024
*
1024
))
if
config
.
UseTLS
{
// Load the certificates from PEM Strings
certificate
,
err
:=
tls
.
X509KeyPair
(
certPEM
,
privateKeyPEM
)
if
err
!=
nil
{
log
.
Printf
(
"Error: %v"
,
err
)
return
fmt
.
Errorf
(
"could not load server key pair: %s"
,
err
)
}
// Create a certificate pool from the certificate authority
// Get the SystemCertPool, continue with an empty pool on error
certPool
,
_
:=
x509
.
SystemCertPool
()
if
certPool
==
nil
{
certPool
=
x509
.
NewCertPool
()
}
if
ok
:=
certPool
.
AppendCertsFromPEM
(
caCertPEM
);
!
ok
{
return
fmt
.
Errorf
(
"failed to append server certs"
)
}
// Create the TLS credentials
creds
:=
credentials
.
NewTLS
(
&
tls
.
Config
{
//ClientAuth: tls.RequireAndVerifyClientCert,
Certificates
:
[]
tls
.
Certificate
{
certificate
},
ClientCAs
:
certPool
,
})
// Create an array of gRPC options with the credentials
opts
=
append
(
opts
,
grpc
.
Creds
(
creds
))
}
// create a server instance
// create a server instance
s
:=
handler
.
KeyStorageServerImpl
{
s
:=
handler
.
KeyStorageServerImpl
{
DataStorageUrl
:
dataStorageAddress
,
DataStorageUrl
:
dataStorageAddress
,
...
@@ -177,39 +212,6 @@ func StartGRPCServer(address string, certPEM, privateKeyPEM, caCertPEM, vereignC
...
@@ -177,39 +212,6 @@ func StartGRPCServer(address string, certPEM, privateKeyPEM, caCertPEM, vereignC
MaxMessageSize
:
maxMessageSize
,
MaxMessageSize
:
maxMessageSize
,
}
}
// Load the certificates from PEM Strings
certificate
,
err
:=
tls
.
X509KeyPair
(
certPEM
,
privateKeyPEM
)
if
err
!=
nil
{
log
.
Printf
(
"Error: %v"
,
err
)
return
fmt
.
Errorf
(
"could not load server key pair: %s"
,
err
)
}
// Create a certificate pool from the certificate authority
// Get the SystemCertPool, continue with an empty pool on error
certPool
,
_
:=
x509
.
SystemCertPool
()
if
certPool
==
nil
{
certPool
=
x509
.
NewCertPool
()
}
if
ok
:=
certPool
.
AppendCertsFromPEM
(
caCertPEM
);
!
ok
{
return
fmt
.
Errorf
(
"failed to append server certs"
)
}
// Create the TLS credentials
creds
:=
credentials
.
NewTLS
(
&
tls
.
Config
{
//ClientAuth: tls.RequireAndVerifyClientCert,
Certificates
:
[]
tls
.
Certificate
{
certificate
},
ClientCAs
:
certPool
,
})
// Create an array of gRPC options with the credentials
opts
:=
[]
grpc
.
ServerOption
{
grpc
.
Creds
(
creds
),
grpc
.
UnaryInterceptor
(
unaryInterceptor
),
grpc
.
MaxRecvMsgSize
(
config
.
MaxMessageSize
*
1024
*
1024
),
}
// create a gRPC server object
// create a gRPC server object
grpcServer
:=
grpc
.
NewServer
(
opts
...
)
grpcServer
:=
grpc
.
NewServer
(
opts
...
)
...
...
This diff is collapsed.
Click to expand it.
utils/utils.go
View file @
cb1d6a09
...
@@ -18,12 +18,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
...
@@ -18,12 +18,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
package
utils
package
utils
import
(
import
(
"code.vereign.com/code/viam-apis/errors"
"crypto/rand"
"crypto/rand"
"crypto/x509"
"crypto/x509"
"fmt"
"fmt"
"io"
"io"
"code.vereign.com/code/viam-apis/errors"
"code.vereign.com/code/viam-apis/log"
"code.vereign.com/code/viam-apis/log"
"encoding/pem"
"encoding/pem"
...
@@ -155,11 +156,11 @@ func GetKey(client *client.DataStorageClientImpl, uuid string, keyType api.KeyTy
...
@@ -155,11 +156,11 @@ func GetKey(client *client.DataStorageClientImpl, uuid string, keyType api.KeyTy
}
}
func
CreateDataStorageClient
(
auth
*
authentication
.
Authentication
)
*
dsclient
.
DataStorageClientImpl
{
func
CreateDataStorageClient
(
auth
*
authentication
.
Authentication
)
*
dsclient
.
DataStorageClientImpl
{
return
clientutils
.
CreateDataStorageClient
(
auth
,
config
.
DataStorageUrl
,
config
.
CertificatePEM
,
return
clientutils
.
CreateDataStorageClient
(
auth
,
config
.
DataStorageUrl
,
config
.
UseTLS
,
config
.
CertificatePEM
,
config
.
PrivateKeyPEM
,
config
.
CaCertificatePEM
,
config
.
MaxMessageSize
)
config
.
PrivateKeyPEM
,
config
.
CaCertificatePEM
,
config
.
MaxMessageSize
)
}
}
func
CreateEntitiesManagementClient
(
auth
*
authentication
.
Authentication
)
*
emclient
.
EntitiesManagerClientImpl
{
func
CreateEntitiesManagementClient
(
auth
*
authentication
.
Authentication
)
*
emclient
.
EntitiesManagerClientImpl
{
return
clientutils
.
CreateEntitiesManagementClient
(
auth
,
config
.
EntitiesManagerUrl
,
config
.
CertificatePEM
,
return
clientutils
.
CreateEntitiesManagementClient
(
auth
,
config
.
EntitiesManagerUrl
,
config
.
UseTLS
,
config
.
CertificatePEM
,
config
.
PrivateKeyPEM
,
config
.
CaCertificatePEM
,
config
.
MaxMessageSize
)
config
.
PrivateKeyPEM
,
config
.
CaCertificatePEM
,
config
.
MaxMessageSize
)
}
}
This diff is collapsed.
Click to expand it.