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

Use the correct ssl key path instead of always the default #15213

Merged
merged 1 commit into from
May 18, 2021

Conversation

dwelch-r7
Copy link
Contributor

@dwelch-r7 dwelch-r7 commented May 18, 2021

Quick PR to use the passed in ssl key path (if provided) instead of the default one which won't be there if you're passing one in 🙃

#15196 (comment)

Verification

  • Ensure there is no key file at ~/.msf4/msf-ws-key.pem
  • Start up the webservice with the --ssl-key-file
  • It should no longer break

@gwillcox-r7
Copy link
Contributor

@msjenkins-r7 test this please

@gwillcox-r7 gwillcox-r7 self-assigned this May 18, 2021
@gwillcox-r7
Copy link
Contributor

For reference since this wasn't exactly described anywhere and was in a chat with @dwelch-r7, the command being tested was ./msfdb reinit --component=all --ssl-key-file "/home/gwillcox/git/asdf core/example.com.key" --ssl-cert-file "/home/gwillcox/git/asdf core/example.com.cert"

@gwillcox-r7
Copy link
Contributor

Before:

 ~/git/asdf core │ master ?3  cat ~/.msf4/msf-ws-key.pem                                                           ✔ │ 2.7.2 Ruby 
A
 ~/git/asdf core │ master ?3  rm -rf ~/.msf4/msf-ws-key.pem                                                        ✔ │ 2.7.2 Ruby 
 ~/git/asdf core │ master ?3  cat ~/.msf4/msf-ws-key.pem                                                           ✔ │ 2.7.2 Ruby 
cat: /home/gwillcox/.msf4/msf-ws-key.pem: No such file or directory
 ~/git/asdf core │ master ?3  ./msfdb reinit --component=all --ssl-key-file "/home/gwillcox/git/asdf core/example.com.key" --ssl-cert-file "/home/gwillcox/git/asdf core/example.com.cert"
[?] Would you like to delete your existing data and configurations?: y
====================================================================
Running the 'reinit' command for the database:
Stopping MSF web service PID 57766
Deleting all data at /home/gwillcox/.msf4/db
Creating database at /home/gwillcox/.msf4/db
Starting database at /home/gwillcox/.msf4/db...success
Creating database users
Writing client authentication configuration file /home/gwillcox/.msf4/.local/etc/postgresql/12/msf/pg_hba.conf
Creating initial database schema
====================================================================

====================================================================
Running the 'reinit' command for the webservice:
MSF web service is no longer running
[?] Initial MSF web service account username? [gwillcox]: 
[?] Initial MSF web service account password? (Leave blank for random password): 
Generating SSL key and certificate for MSF web service
Attempting to start MSF web service...failed
[!] The SSL Key needed for the webservice to connect to the database could not be found at /home/gwillcox/.msf4/msf-ws-key.pem.
[!] Has the webservice been initialized with "msfdb init"  or "msfdb init --component webservice"?
====================================================================

 ~/git/asdf core │ master ?3                                                                                 ✔ │ 31s │ 2.7.2 Ruby 

After:

 ~/git/asdf core │ @aab54892 ?3  git checkout upstream/pr/15213 -b land-pr15213                                    ✔ │ 2.7.2 Ruby 
Branch 'land-pr15213' set up to track remote branch 'pr/15213' from 'upstream'.
Switched to a new branch 'land-pr15213'
 ~/git/asdf core │ land-pr15213:pr/15213 ?3  cat ~/.msf4/msf-ws-key.pem                                            ✔ │ 2.7.2 Ruby 
cat: /home/gwillcox/.msf4/msf-ws-key.pem: No such file or directory
 ~/git/asdf core │ land-pr15213:pr/15213 ?3  ./msfdb reinit --component=all --ssl-key-file "/home/gwillcox/git/asdf core/example.com.key" --ssl-cert-file "/home/gwillcox/git/asdf core/example.com.cert"
[?] Would you like to delete your existing data and configurations?: y
====================================================================
Running the 'reinit' command for the database:
MSF web service is no longer running
Deleting all data at /home/gwillcox/.msf4/db
Creating database at /home/gwillcox/.msf4/db
Starting database at /home/gwillcox/.msf4/db...success
Creating database users
Writing client authentication configuration file /home/gwillcox/.msf4/.local/etc/postgresql/12/msf/pg_hba.conf
Creating initial database schema
====================================================================

====================================================================
Running the 'reinit' command for the webservice:
MSF web service is no longer running
[?] Initial MSF web service account username? [gwillcox]: 
[?] Initial MSF web service account password? (Leave blank for random password): 
Generating SSL key and certificate for MSF web service
Attempting to start MSF web service...success
MSF web service started and online
Creating MSF web service user gwillcox

    ############################################################
    ##              MSF Web Service Credentials               ##
    ##                                                        ##
    ##        Please store these credentials securely.        ##
    ##    You will need them to connect to the webservice.    ##
    ############################################################

MSF web service username: gwillcox
MSF web service password: *censored*
MSF web service user API token: *censored*


MSF web service configuration complete
The web service has been configured as your default data service in msfconsole with the name "local-https-data-service"

If needed, manually reconnect to the data service in msfconsole using the command:
db_connect --name local-https-data-service --token *censored* --cert /home/gwillcox/git/asdf core/example.com.cert --skip-verify https://localhost:5443

The username and password are credentials for the API account:
https://localhost:5443/api/v1/auth/account

====================================================================

 ~/git/asdf core │ land-pr15213:pr/15213 ?3   

@gwillcox-r7 gwillcox-r7 mentioned this pull request May 18, 2021
1 task
@gwillcox-r7 gwillcox-r7 added bug rn-fix release notes fix labels May 18, 2021
@gwillcox-r7
Copy link
Contributor

@msjenkins-r7 test this please

1 similar comment
@gwillcox-r7
Copy link
Contributor

@msjenkins-r7 test this please

@gwillcox-r7 gwillcox-r7 merged commit 6d50dde into rapid7:master May 18, 2021
@gwillcox-r7
Copy link
Contributor

gwillcox-r7 commented May 18, 2021

Release Notes

Fixed msfdb to use the passed in SSL key path (if provided) instead of the default one at ~/.msf4/msf-ws-key.pem, which may not exist if users have passed in a SSL key path as an option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug rn-fix release notes fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants