diff --git a/client/src/actions/encryption.js b/client/src/actions/encryption.js index a537f31d..4e259409 100644 --- a/client/src/actions/encryption.js +++ b/client/src/actions/encryption.js @@ -1,6 +1,7 @@ import { createAction } from 'redux-actions'; import Api from '../api/Api'; import { addErrorToast, addSuccessToast } from './index'; +import { redirectToCurrentProtocol } from '../helpers/helpers'; const apiClient = new Api(); @@ -40,6 +41,7 @@ export const setTlsConfig = config => async (dispatch) => { response.private_key = atob(response.private_key); dispatch(setTlsConfigSuccess(response)); dispatch(addSuccessToast('encryption_config_saved')); + redirectToCurrentProtocol(response); } catch (error) { dispatch(addErrorToast({ error })); dispatch(setTlsConfigFailure()); diff --git a/client/src/components/Settings/Encryption/Form.js b/client/src/components/Settings/Encryption/Form.js index f3d83e29..a82dfca0 100644 --- a/client/src/components/Settings/Encryption/Form.js +++ b/client/src/components/Settings/Encryption/Form.js @@ -48,9 +48,11 @@ let Form = (props) => { invalid, submitting, processing, + processingValidate, not_after, valid_chain, valid_key, + valid_cert, dns_names, key_type, issuer, @@ -260,7 +262,11 @@ let Form = (props) => {

- {warning_validation && warning_validation} + { + (certificateChain || privateKey) + && warning_validation + && warning_validation + }

@@ -273,7 +279,9 @@ let Form = (props) => { invalid || submitting || processing - || !valid_key + || processingValidate + || (privateKey && !valid_key) + || (certificateChain && !valid_cert) } > save_config @@ -302,11 +310,13 @@ Form.propTypes = { invalid: PropTypes.bool.isRequired, initialValues: PropTypes.object.isRequired, processing: PropTypes.bool.isRequired, + processingValidate: PropTypes.bool.isRequired, status_key: PropTypes.string, not_after: PropTypes.string, warning_validation: PropTypes.string, valid_chain: PropTypes.bool, valid_key: PropTypes.bool, + valid_cert: PropTypes.bool, dns_names: PropTypes.string, key_type: PropTypes.string, issuer: PropTypes.string, diff --git a/client/src/components/Settings/Encryption/index.js b/client/src/components/Settings/Encryption/index.js index 0d56fc75..9e9e0626 100644 --- a/client/src/components/Settings/Encryption/index.js +++ b/client/src/components/Settings/Encryption/index.js @@ -46,6 +46,7 @@ class Encryption extends Component { private_key, }} processing={encryption.processingConfig} + processingValidate={encryption.processingValidate} onSubmit={this.handleFormSubmit} onChange={this.handleFormChange} {...this.props.encryption} diff --git a/client/src/helpers/helpers.js b/client/src/helpers/helpers.js index 0630416d..def06646 100644 --- a/client/src/helpers/helpers.js +++ b/client/src/helpers/helpers.js @@ -140,3 +140,15 @@ export const getWebAddress = (ip, port = '') => { return address; }; + +export const redirectToCurrentProtocol = (values) => { + const { protocol, hostname, hash } = window.location; + const { enabled, port_https } = values; + + if (protocol !== 'https:' && enabled && port_https) { + const port = port_https !== 443 ? `:${port_https}` : ''; + window.location.replace(`https://${hostname}${port}/${hash}`); + } else if (protocol === 'https:' && (!enabled || !port_https)) { + window.location.replace(`http://${hostname}/${hash}`); + } +}; diff --git a/client/src/reducers/encryption.js b/client/src/reducers/encryption.js index 5986f987..f3f2dd67 100644 --- a/client/src/reducers/encryption.js +++ b/client/src/reducers/encryption.js @@ -46,11 +46,12 @@ const encryption = handleActions({ key_type: '', not_after: '', not_before: '', - port_dns_over_tls: 853, - port_https: 443, + port_dns_over_tls: '', + port_https: '', subject: '', valid_chain: false, valid_key: false, + valid_cert: false, status_cert: '', status_key: '', certificate_chain: '',