How to fix bundle installation error with SSL in Ruby 3?

During bundle installation in Ruby 3, programmers are facing following error-
Gem::RemoteFetcher::FetchError: SSL_connect returned=1 errno=0 state=SSLv3 read server
certificate B: certificate verify failed ( 10.4.2.gem)
An error occurred while installing rake (10.4.2), and Bundler cannot continue.
Make sure that `gem install rake -v '10.4.2'' succeeds before bundling.

Note: “Gemfile” located inside your project root folder.

To fix the error and make the update successful, we can use following procedure-
1. Remove secure connection
gem sources -r

2. Add insecure connection
gem sources -a

3. Update rubygems without SSL
gem update --system

4. Remove insecure connection
gem sources -r

5. Add secure connection
gem sources -a

6. Update gems
gem update

Hope this will work for all.