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

GDS: fix Application unregistration in SQL DB for Winforms Server & fix private key storage in Pull Model GDS Client #598

Merged
8 changes: 4 additions & 4 deletions Samples/ClientControls.Net4/UA Client Controls.csproj
Expand Up @@ -1015,16 +1015,16 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Core">
<Version>1.5.374.27</Version>
<Version>1.5.374.36</Version>
</PackageReference>
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Client">
<Version>1.5.374.27</Version>
<Version>1.5.374.36</Version>
</PackageReference>
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Client.ComplexTypes">
<Version>1.5.374.27</Version>
<Version>1.5.374.36</Version>
</PackageReference>
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Configuration">
<Version>1.5.374.27</Version>
<Version>1.5.374.36</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
Expand Down
22 changes: 8 additions & 14 deletions Samples/GDS/Client/Controls/ApplicationCertificateControl.cs
Expand Up @@ -93,8 +93,7 @@ public ApplicationCertificateControl()
}
else if (!String.IsNullOrEmpty(application.CertificateStorePath))
{
CertificateIdentifier id = new CertificateIdentifier
{
CertificateIdentifier id = new CertificateIdentifier {
StorePath = application.CertificateStorePath
};
id.StoreType = CertificateStoreIdentifier.DetermineStoreType(id.StorePath);
Expand Down Expand Up @@ -125,8 +124,7 @@ public ApplicationCertificateControl()
{
Uri url = new Uri(disoveryUrl);

CertificateIdentifier id = new CertificateIdentifier()
{
CertificateIdentifier id = new CertificateIdentifier() {
StoreType = CertificateStoreType.X509Store,
StorePath = "CurrentUser\\UA_MachineDefault",
SubjectName = "CN=" + url.DnsSafeHost
Expand Down Expand Up @@ -216,11 +214,10 @@ private async Task RequestNewCertificatePullMode(object sender, EventArgs e)
NodeId requestId = null;
if (!string.IsNullOrEmpty(m_application.CertificateStorePath))
{
CertificateIdentifier id = new CertificateIdentifier
{
CertificateIdentifier id = new CertificateIdentifier {
StoreType = CertificateStoreIdentifier.DetermineStoreType(m_application.CertificateStorePath),
StorePath = m_application.CertificateStorePath,
SubjectName = m_application.CertificateSubjectName.Replace("localhost", Utils.GetHostName())
SubjectName = Utils.ReplaceDCLocalhost(m_application.CertificateSubjectName)
};
m_certificate = await id.Find(true);
if (m_certificate != null &&
Expand All @@ -245,7 +242,7 @@ private async Task RequestNewCertificatePullMode(object sender, EventArgs e)
m_application.ApplicationId,
NodeId.Null,
NodeId.Null,
m_application.CertificateSubjectName.Replace("localhost", Utils.GetHostName()),
Utils.ReplaceDCLocalhost(m_application.CertificateSubjectName),
domainNames,
"PFX",
m_certificatePassword);
Expand Down Expand Up @@ -316,15 +313,14 @@ private async void CertificateRequestTimer_Tick(object sender, EventArgs e)

if (!String.IsNullOrEmpty(m_application.CertificateStorePath) && !String.IsNullOrEmpty(m_application.CertificateSubjectName))
{
CertificateIdentifier cid = new CertificateIdentifier()
{
CertificateIdentifier cid = new CertificateIdentifier() {
StorePath = m_application.CertificateStorePath,
StoreType = CertificateStoreIdentifier.DetermineStoreType(m_application.CertificateStorePath),
SubjectName = m_application.CertificateSubjectName.Replace("localhost", Utils.GetHostName())
SubjectName = Utils.ReplaceDCLocalhost(m_application.CertificateSubjectName)
};

// update store
using (var store = CertificateStoreIdentifier.OpenStore(m_application.CertificateStorePath))
using (ICertificateStore store = CertificateStoreIdentifier.OpenStore(m_application.CertificateStorePath, false))
{
// if we used a CSR, we already have a private key and therefore didn't request one from the GDS
// in this case, privateKey is null
Expand All @@ -347,8 +343,6 @@ private async void CertificateRequestTimer_Tick(object sender, EventArgs e)
newCert = new X509Certificate2(privateKeyPFX, string.Empty, X509KeyStorageFlags.Exportable);
newCert = CertificateFactory.Load(newCert, true);
}

// bugbug: private key is not saved to store
await store.Add(newCert);
}
}
Expand Down
4 changes: 2 additions & 2 deletions Samples/GDS/Client/GlobalDiscoveryClient.csproj
Expand Up @@ -139,10 +139,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Configuration">
<Version>1.5.374.27</Version>
<Version>1.5.374.36</Version>
</PackageReference>
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Gds.Client.Common">
<Version>1.5.374.27</Version>
<Version>1.5.374.36</Version>
</PackageReference>
<PackageReference Include="System.Net.Http">
<Version>4.3.4</Version>
Expand Down
Expand Up @@ -217,10 +217,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Client">
<Version>1.5.374.27</Version>
<Version>1.5.374.36</Version>
</PackageReference>
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Gds.Client.Common">
<Version>1.5.374.27</Version>
<Version>1.5.374.36</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions Samples/GDS/ConsoleServer/NetCoreGlobalDiscoveryServer.csproj
Expand Up @@ -14,8 +14,8 @@
<ItemGroup>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.6" />
<PackageReference Include="Mono.Options" Version="6.12.0.148" />
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Gds.Server.Common" Version="1.5.374.27" />
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Configuration" Version="1.5.374.27" />
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Gds.Server.Common" Version="1.5.374.36" />
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Configuration" Version="1.5.374.36" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions Samples/GDS/Server/GlobalDiscoveryServer.csproj
Expand Up @@ -235,10 +235,10 @@
<Version>6.4.4</Version>
</PackageReference>
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Configuration">
<Version>1.5.374.27</Version>
<Version>1.5.374.36</Version>
</PackageReference>
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Gds.Server.Common">
<Version>1.5.374.27</Version>
<Version>1.5.374.36</Version>
</PackageReference>
</ItemGroup>
<PropertyGroup>
Expand Down
5 changes: 5 additions & 0 deletions Samples/GDS/Server/SqlApplicationsDatabase.cs
Expand Up @@ -169,6 +169,11 @@ public override void UnregisterApplication(NodeId applicationId)
entities.CertificateRequests.Remove(entry);
}

foreach (var entry in new List<CertificateStore>(result.CertificateStores))
{
entities.CertificateStores.Remove(entry);
}

foreach (var entry in new List<ApplicationName>(result.ApplicationNames))
{
entities.ApplicationNames.Remove(entry);
Expand Down
6 changes: 3 additions & 3 deletions Samples/ServerControls.Net4/UA Server Controls.csproj
Expand Up @@ -148,13 +148,13 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Core">
<Version>1.5.374.27</Version>
<Version>1.5.374.36</Version>
</PackageReference>
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Configuration">
<Version>1.5.374.27</Version>
<Version>1.5.374.36</Version>
</PackageReference>
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Server">
<Version>1.5.374.27</Version>
<Version>1.5.374.36</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down