title: Please create a master key in the database or open the master key in the session before performing this operation
body: <p>I get the following error on secondary replicas when trying to restore an encrypted backup even though the replica has the master key (dmk), service master key, certificates and private keys restored from the originating/primary server that generated the backup.</p>
  
  <pre><code>Msg 15581, Level 16, State 7, Line 137
  Please create a master key in the database or open the master key in the session before performing this operation.
  Msg 3013, Level 16, State 1, Line 137
  VERIFY DATABASE is terminating abnormally.
  </code></pre>
  
  <p>To circumvent the error I open and close the master key around the operation like such. However, on the primary, I don't need to open and close the master key to do the operation. </p>
  
  <pre><code>OPEN MASTER KEY DECRYPTION BY PASSWORD = 'MyTest!M4st3rPass';
  RESTORE VERIFYONLY FROM DISK = '\\FS1\SqlBackups\SQL01\SystemDbs\msdb_backup_2017_09_22_171915_6346240.bak' WITH FILE = 1, NOUNLOAD, NOREWIND;
  CLOSE MASTER KEY ;
  </code></pre>
  
  <p>I believe this is because the primary has the backup history with the encryption thumbprint, but I am wondering if I am missing something else related to the secondaries.</p>
  
  <p>However, after all, since the cert is restored on the secondaries I assign it to the SystemsDB Backup Maintenance Plan options for Backup Encryption, yet the job fails if I keep the Verify option checked for the same reason. </p>
  
  <pre><code>Source: Back Up Database Task
  Executing query "BACKUP DATABASE [master] TO  DISK = N'\\FS1\SqlBac...".: 50% complete
  End Progress  
  Error: 2017-09-22 17:08:09.28
  Code: 0xC002F210
  Source: Back Up Database Task Execute SQL Task
  **Description**: Executing the query "declare @backupSetId as int  select @backupSetId =..." 
  failed with the following error: "Please create a master key in the database or open the master key in the session before performing this operation.
  VERIFY DATABASE is terminating abnormally.".
  Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
  End Error 
  </code></pre>