Skip to content

Commit

Permalink
fix TLS
Browse files Browse the repository at this point in the history
  • Loading branch information
levichevdmitry committed Jul 24, 2023
1 parent a1901d1 commit 887b0a6
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
22 changes: 11 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module github.com/pip-services3-go/pip-services3-rpc-go

go 1.16

require (
github.com/gorilla/handlers v1.5.1
github.com/gorilla/mux v1.8.0
github.com/pip-services3-go/pip-services3-commons-go v1.1.6
github.com/pip-services3-go/pip-services3-components-go v1.3.2
github.com/stretchr/testify v1.8.1
)
module github.com/pip-services3-go/pip-services3-rpc-go

go 1.16

require (
github.com/gorilla/handlers v1.5.1
github.com/gorilla/mux v1.8.0
github.com/pip-services3-go/pip-services3-commons-go v1.1.6
github.com/pip-services3-go/pip-services3-components-go v1.3.2
github.com/stretchr/testify v1.8.1
)
25 changes: 22 additions & 3 deletions services/HttpEndpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,26 +209,45 @@ func (c *HttpEndpoint) Open(correlationId string) error {

c.performRegistrations()

chErr := make(chan error, 1)
defer close(chErr)

if connection.Protocol() == "https" {
sslKeyFile := credential.GetAsString("ssl_key_file")
sslCrtFile := credential.GetAsString("ssl_crt_file")

go func() {
servErr := c.server.ListenAndServeTLS(sslKeyFile, sslCrtFile)
servErr := c.server.ListenAndServeTLS(sslCrtFile, sslKeyFile)
if servErr != nil {
//fmt.Println("Server stoped:", servErr.Error())
select {
default:
chErr <- err
case <-chErr:
}
}
}()

} else {
go func() {
servErr := c.server.ListenAndServe()
if servErr != nil {
//fmt.Println("Server stoped:", servErr.Error())
select {
default:
chErr <- err
case <-chErr:
}
}
}()
}

// waiting 1 second for start up services
select {
case <-time.After(time.Second):
case err := <-chErr:
c.logger.Error(correlationId, err, "ERROR_STARTUP_SERVICE", "Can't start REST service at %s", c.uri)
return err
}

regErr := c.connectionResolver.Register(correlationId)
if regErr != nil {
c.logger.Error(correlationId, regErr, "ERROR_REG_SRV", "Can't register REST service at %s", c.uri)
Expand Down

0 comments on commit 887b0a6

Please sign in to comment.