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

R4R: reintroduce gaia server's insecure mode #3317

Merged
merged 1 commit into from
Jan 17, 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
1 change: 1 addition & 0 deletions PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ FEATURES
* [\#3198](https://github.com/cosmos/cosmos-sdk/issues/3198) New `keys add --multisig` flag to store multisig keys locally.
* [\#3198](https://github.com/cosmos/cosmos-sdk/issues/3198) New `multisign` command to generate multisig signatures.
* [\#3198](https://github.com/cosmos/cosmos-sdk/issues/3198) New `sign --multisig` flag to enable multisig mode.
* [\#2715](https://github.com/cosmos/cosmos-sdk/issues/2715) Reintroduce gaia server's insecure mode.

* Gaia
* [\#2182] [x/staking] Added querier for querying a single redelegation
Expand Down
88 changes: 36 additions & 52 deletions client/lcd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,68 +77,52 @@ func (rs *RestServer) Start(listenAddr string, sslHosts string,
rs.log.Error("error closing listener", "err", err)
})

// TODO: re-enable insecure mode once #2715 has been addressed
rs.listener, err = rpcserver.Listen(
listenAddr,
rpcserver.Config{MaxOpenConnections: maxOpen},
)
if err != nil {
return
}
rs.log.Info("Starting Gaia Lite REST service...")

// launch rest-server in insecure mode
if insecure {
fmt.Println(
"Insecure mode is temporarily disabled, please locally generate an " +
"SSL certificate to test. Support will be re-enabled soon!",
)
// listener, err = rpcserver.StartHTTPServer(
// listenAddr, handler, logger,
// rpcserver.Config{MaxOpenConnections: maxOpen},
// )
// if err != nil {
// return
// }
} else {
if certFile != "" {
// validateCertKeyFiles() is needed to work around tendermint/tendermint#2460
err = validateCertKeyFiles(certFile, keyFile)
if err != nil {
return err
}

// cert/key pair is provided, read the fingerprint
rs.fingerprint, err = fingerprintFromFile(certFile)
if err != nil {
return err
}
} else {
// if certificate is not supplied, generate a self-signed one
certFile, keyFile, rs.fingerprint, err = genCertKeyFilesAndReturnFingerprint(sslHosts)
if err != nil {
return err
}

defer func() {
os.Remove(certFile)
os.Remove(keyFile)
}()
return rpcserver.StartHTTPServer(rs.listener, rs.Mux, rs.log)
}

// handle certificates
if certFile != "" {
// validateCertKeyFiles() is needed to work around tendermint/tendermint#2460
if err := validateCertKeyFiles(certFile, keyFile); err != nil {
return err
}

rs.listener, err = rpcserver.Listen(
listenAddr,
rpcserver.Config{MaxOpenConnections: maxOpen},
)
// cert/key pair is provided, read the fingerprint
rs.fingerprint, err = fingerprintFromFile(certFile)
if err != nil {
return
return err
}

rs.log.Info("Starting Gaia Lite REST service...")
rs.log.Info(rs.fingerprint)

err := rpcserver.StartHTTPAndTLSServer(
rs.listener,
rs.Mux,
certFile, keyFile,
rs.log,
)
} else {
// if certificate is not supplied, generate a self-signed one
certFile, keyFile, rs.fingerprint, err = genCertKeyFilesAndReturnFingerprint(sslHosts)
if err != nil {
return err
}

defer func() {
os.Remove(certFile)
os.Remove(keyFile)
}()
}

return nil
rs.log.Info(rs.fingerprint)
return rpcserver.StartHTTPAndTLSServer(
rs.listener,
rs.Mux,
certFile, keyFile,
rs.log,
)
}

// ServeCommand will start a Gaia Lite REST service as a blocking process. It
Expand Down