Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reads thumbprint of desired X509 certificate from file #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PluginVersion.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
:
SmartCertificateKeyProviderPlugin:2.0.1
SmartCertificateKeyProviderPlugin:2.0.2
:
2 changes: 1 addition & 1 deletion Source/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("SmartCertificateKeyProviderPlugin")]
[assembly: AssemblyDescription("This plugin uses X.509 certificate from your personal certificate storage to encrypt KeePass database with generated SHA1 hash from certificate's signature. It also allow to use certificates that are on your Smart Card. It is possible to use Secure Desktop feature (needs to be enabled in Options - Security tab) to avoid Keyloggers.\nDON'T LOOSE YOUR CERTIFICATE OR YOU WILL NOT BE ABLE TO OPEN YOUR DATABASE.")]
[assembly: AssemblyDescription("This plugin uses X.509 certificate from your personal certificate storage to encrypt KeePass database with generated SHA1 hash from certificate's signature. It also allow to use certificates that are on your Smart Card. It is possible to use Secure Desktop feature (needs to be enabled in Options - Security tab) to avoid Keyloggers.\nDON'T LOSE YOUR CERTIFICATE OR YOU WILL NOT BE ABLE TO OPEN YOUR DATABASE.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("BodnarSoft")]
[assembly: AssemblyProduct("KeePass Plugin")]
Expand Down
32 changes: 13 additions & 19 deletions Source/Smart Certificate KeyProvider.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="packages\GitVersionTask.5.1.3\build\GitVersionTask.props" Condition="Exists('packages\GitVersionTask.5.1.3\build\GitVersionTask.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand Down Expand Up @@ -61,32 +62,25 @@
<None Include="packages.config" />
<None Include="Smart Certificate KeyProvider.ruleset" />
</ItemGroup>
<ItemGroup>
<Analyzer Include="packages\StyleCop.Analyzers.1.0.2\analyzers\dotnet\cs\StyleCop.Analyzers.CodeFixes.dll" />
<Analyzer Include="packages\StyleCop.Analyzers.1.0.2\analyzers\dotnet\cs\StyleCop.Analyzers.dll" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="packages\GitVersionTask.3.6.5\build\dotnet\GitVersionTask.targets" Condition="Exists('packages\GitVersionTask.3.6.5\build\dotnet\GitVersionTask.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\GitVersionTask.3.6.5\build\dotnet\GitVersionTask.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\GitVersionTask.3.6.5\build\dotnet\GitVersionTask.targets'))" />
</Target>
<Target Name="WriteVersionFile" AfterTargets="Build">
<ItemGroup>
<PluginVersion Include=":"/>
<PluginVersion Include="$(TargetName):$(GitVersion_MajorMinorPatch)"/>
<PluginVersion Include=":"/>
<PluginVersion Include=":" />
<PluginVersion Include="$(TargetName):$(GitVersion_MajorMinorPatch)" />
<PluginVersion Include=":" />
</ItemGroup>
<WriteLinesToFile
File="$(SolutionDir)..\PluginVersion.txt"
Lines="@(PluginVersion)"
Overwrite="true"
Encoding="UTF-8"/>
<WriteLinesToFile File="$(SolutionDir)..\PluginVersion.txt" Lines="@(PluginVersion)" Overwrite="true" Encoding="UTF-8" />
</Target>
<PropertyGroup>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\GitVersionTask.5.1.3\build\GitVersionTask.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\GitVersionTask.5.1.3\build\GitVersionTask.props'))" />
<Error Condition="!Exists('packages\GitVersionTask.5.1.3\build\GitVersionTask.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\GitVersionTask.5.1.3\build\GitVersionTask.targets'))" />
</Target>
<Import Project="packages\GitVersionTask.5.1.3\build\GitVersionTask.targets" Condition="Exists('packages\GitVersionTask.5.1.3\build\GitVersionTask.targets')" />
</Project>
12 changes: 6 additions & 6 deletions Source/Smart Certificate KeyProvider.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.2011
# Visual Studio Version 16
VisualStudioVersion = 16.0.29613.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Smart Certificate KeyProvider", "Smart Certificate KeyProvider.csproj", "{1FBC0E45-0C76-4346-967B-10D681FB712E}"
EndProject
Expand All @@ -17,10 +17,10 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1FBC0E45-0C76-4346-967B-10D681FB712E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1FBC0E45-0C76-4346-967B-10D681FB712E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1FBC0E45-0C76-4346-967B-10D681FB712E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1FBC0E45-0C76-4346-967B-10D681FB712E}.Release|Any CPU.Build.0 = Release|Any CPU
{1FBC0E45-0C76-4346-967B-10D681FB712E}.Debug|Any CPU.ActiveCfg = Release|Any CPU
{1FBC0E45-0C76-4346-967B-10D681FB712E}.Debug|Any CPU.Build.0 = Release|Any CPU
{1FBC0E45-0C76-4346-967B-10D681FB712E}.Release|Any CPU.ActiveCfg = Debug|Any CPU
{1FBC0E45-0C76-4346-967B-10D681FB712E}.Release|Any CPU.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
15 changes: 12 additions & 3 deletions Source/SmartCertificateKeyProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,18 @@ private static X509Certificate2[] UserCertificates
var myStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
myStore.Open(OpenFlags.ReadOnly);

var certificates = myStore.Certificates.Cast<X509Certificate2>()
.Where(c => c.HasPrivateKey)
.ToArray();
X509Certificate2[] certificates = myStore.Certificates.Cast<X509Certificate2>()
.Where(c => c.HasPrivateKey)
.ToArray();

if (System.IO.File.Exists("X509_thumbprint.txt"))
{
System.IO.StreamReader file = new System.IO.StreamReader(@"X509_thumbprint.txt");
string thumbprint = file.ReadLine();
file.Close();
X509Certificate2Collection matching_certificates = myStore.Certificates.Find(X509FindType.FindByThumbprint, thumbprint, true);
certificates = matching_certificates.Cast<X509Certificate2>().ToArray();
}

myStore.Close();

Expand Down
2 changes: 1 addition & 1 deletion Source/SmartCertificateKeyProviderPluginExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public SmartCertificateKeyProviderPluginExt()

#region Public properties

public override string UpdateUrl => "https://raw.githubusercontent.com/BodnarSoft/KeePass-Smart-Certificate-Key-Provider/master/PluginVersion.txt";
public override string UpdateUrl => "https://raw.githubusercontent.com/jimmyswimmy/KeePass-Smart-Certificate-Key-Provider/master/PluginVersion.txt";

#endregion

Expand Down