[SERVER-10619] Mongod doesn't start with --keyFile option on windows Created: 24/Aug/13  Updated: 10/Dec/14  Resolved: 30/Nov/13

Status: Closed
Project: Core Server
Component/s: Security
Affects Version/s: 2.4.6
Fix Version/s: None

Type: Bug Priority: Blocker - P1
Reporter: aftab khan Assignee: Andy Schwerin
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

ALL


Operating System: ALL
Steps To Reproduce:

-- On powershell 
-- Generate key file
 
PS C:\> openssl rand -base64 60 > c:\key_file
Loading 'screen' into random state - done
 
-- Start mongod using --keyFile
 
PS C:\> mongod --dbpath 1 --keyFile C:\key_file
Sat Aug 24 10:17:26.230 invalid char in key file C:\key_file: ?

We can verify key_file contents:

PS C:\> type c:\key_file
QC4wVN/ad/vTskKtZ0lysAAG4GEoGFCd7FyStRlu3ZUn+ayAakEuP1Jtj7RFKPRS
RVeZS/lhYz6oYrSr

Participants:

 Description   

Mongod refuse to start when --keyFile option is used:

-- On powershell 
-- Generate key file
 
PS C:\> openssl rand -base64 60 > c:\key_file
Loading 'screen' into random state - done
 
-- Start mongod using --keyFile
 
PS C:\> mongod --dbpath 1 --keyFile C:\key_file
Sat Aug 24 10:17:26.230 invalid char in key file C:\key_file: ?

We can verify key_file contents:

PS C:\> type c:\key_file
QC4wVN/ad/vTskKtZ0lysAAG4GEoGFCd7FyStRlu3ZUn+ayAakEuP1Jtj7RFKPRS
RVeZS/lhYz6oYrSr

Mongod starts without a problem when --keyFile option is not specified:

PS C:\> mongod --dbpath 1
Sat Aug 24 10:24:53.596 [initandlisten] MongoDB starting : pid=3616 port=27017 dbpath=1 64-bit host=aftab-HP
Sat Aug 24 10:24:53.599 [initandlisten] db version v2.4.5
Sat Aug 24 10:24:53.600 [initandlisten] git version: a2ddc68ba7c9cee17bfe69ed840383ec3506602b
Sat Aug 24 10:24:53.602 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform
=2, service_pack='Service Pack 1') BOOST_LIB_VERSION=1_49
Sat Aug 24 10:24:53.604 [initandlisten] allocator: system
Sat Aug 24 10:24:53.606 [initandlisten] options: { dbpath: "1" }
Sat Aug 24 10:24:53.623 [initandlisten] journal dir=1\journal
Sat Aug 24 10:24:53.624 [initandlisten] recover : no journal files present, no recovery needed
Sat Aug 24 10:24:53.958 [initandlisten] waiting for connections on port 27017
Sat Aug 24 10:24:53.958 [websvr] admin web console waiting for connections on port 28017



 Comments   
Comment by Eliot Horowitz (Inactive) [ 30/Nov/13 ]

If you need more help, please let us know.

Comment by Sridhar Nanjundeswaran [ 26/Aug/13 ]

Hi Aftab,
If you generated the key file from a powershell window it stores as UTF-16 by default. I would suggest using the same command from a regular command shell or opening the key file you generated from an editor such as notepad and saving it with ASCII encoding.

Comment by Andy Schwerin [ 26/Aug/13 ]

Can you verify that the keyfile is encoded in ASCII or UTF-8? The most likely culprit is that the file is somehow encoded in UTF-16 (Windows wide character). If you can attach a breaking keyfile to this ticket, that would be helpful.

Generated at Thu Feb 08 03:23:38 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.