SSL_connect returned=1 errno=0 state=error: certificate verify failed (unable to get local issuer certificate)
Steps to reproduce
- add
{prerender: true}toreact_component
Expected behavior
Component to be server side rendered
Actual behavior
SSL_connect returned=1 errno=0 state=error: certificate verify failed (unable to get local issuer certificate) at runtime
System configuration
Webpacker version: 4.0.7 React-Rails version: 2.5.0 React_UJS version: 2.5.0 Rails version: 5.2.3 Ruby version: 2.6.3
When adding {prerender: true} to react_component component tag, server throws error at runtime. I'm using https://github.com/puma/puma-dev with .test domain and puma-dev has it's own self-signed certificate that was added to keychain and trust.
I temporarily solved locally by changing this line:
https://github.com/reactjs/react-rails/blob/344ba138a5c827a4d9e55787b5afc0f477a609f1/lib/react/server_rendering/webpacker_manifest_container.rb#L47
to:
dev_server_asset = open(
"#{ds.protocol}://#{ds.host_with_port}#{asset_path}",
{ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE}
).read
I would say that it should be safe to not verify when dealing with a local webpack-dev-server connection but it's probably more savvy to check how certs are managed by webpacker, and also avoid using open-uri if possible 🙏
@elia You have suggested a temporary solution for this. Closing the issue for now.