private static string Find(string filePath) { var hash = new HashSet <string>(); byte[] keyData = File.ReadAllBytes(filePath); foreach (string password in _keyFilePasswordByPath.Values) { if (hash.Contains(password)) { continue; } if (StrongNameUtils.IsPasswordValid(keyData, password)) { return(password); } hash.Add(password); } var passwordViewModel = new PKCS12PasswordViewModel(AppService.Shell, filePath); AppService.UI.ShowPKCS12Password(passwordViewModel); return(passwordViewModel.Password); }
private void SignBrowseForKeyFile() { string filePath = AppService.UI.ShowOpenFileDialog( Constants.StrongNameKeyFileFilter, SR.OpenFileCaption); if (string.IsNullOrEmpty(filePath)) { return; } if (!File.Exists(filePath)) { return; } string password = null; if (StrongNameUtils.IsPKCS12File(filePath)) { if (!StrongNamePasswordCache.TryGet(filePath, out password)) { return; } } _projectSign.KeyFile = filePath; _projectSign.Password = password; OnPropertyChanged("SignKeyFile"); OnProjectChanged(); }
private void Sign(ModuleState state) { byte[] keyPair = File.ReadAllBytes(state.StrongNameKeyFilePath); if (!string.IsNullOrEmpty(state.StrongNameKeyPassword)) { keyPair = StrongNameUtils.ExtractKeyPairFromPKCS12(keyPair, state.StrongNameKeyPassword); } foreach (string filePath in state.SignFiles) { StrongNameUtils.SignAssemblyFromKeyPair(filePath, keyPair, StrongNameGenerationFlags.None); } }
private void LoadStrongName(MSBuildAssembly assembly, Build.Project project, string projectFolder) { string keyFile = GetKeyFile(project, projectFolder); string password = null; if (StrongNameUtils.IsPKCS12File(keyFile)) { if (!StrongNamePasswordCache.TryGet(keyFile, out password)) { return; } } assembly.Sign = true; assembly.DelaySign = IsDelaySign(project); assembly.KeyFilePath = keyFile; assembly.KeyPassword = password; }
private bool IsPasswordValid() { if (string.IsNullOrEmpty(_password)) { return(false); } if (!File.Exists(_filePath)) { return(false); } if (!StrongNameUtils.IsPasswordValid(_filePath, _password)) { return(false); } return(true); }