Backup and restore Keychain
Save the keychain folder(/Users/[UserName]/Library/Keychains) on an external drive or in the cloud.  
After the reinstall, then replace the "/Users/[UserName]/Library/Keychains" with the data you saved in the step before. 


(Some of your keys may already be saved in iCloud)