The Letter of Marque by Patrick O'Brian
Captain Jack Aubrey, a brilliant and experienced officer, has been struck off the list of post-captains for a crime he did not commit. His old friend Stephen Maturin, usually cast as a ship's surgeon to mask his discreet activities on behalf of British Intelligence, has bought for Aubrey his former ship the Surprise to command as a privateer, more politely termed a letter of marque. Together they sail on a desperate mission against the French, which, if successful, may redeem Aubrey from the private hell of his disgrace.