Skip to content

Commit 8f21ea4

Browse files
committed
Update solutions for 377 Update
1 parent 20e7334 commit 8f21ea4

File tree

79 files changed

+216
-207
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+216
-207
lines changed

Samples/Client.Net4/Program.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ static void Main()
5353

5454
try
5555
{
56-
application.LoadApplicationConfiguration(false).Wait();
56+
application.LoadApplicationConfigurationAsync(false).GetAwaiter().GetResult();
5757

5858
// check the application certificate.
59-
bool certOK = application.CheckApplicationInstanceCertificates(false).Result;
59+
bool certOK = application.CheckApplicationInstanceCertificatesAsync(false).Result;
6060
if (!certOK)
6161
{
6262
throw new Exception("Application instance certificate invalid!");
6363
}
6464

6565
// start the server.
66-
application.Start(new SampleServer()).Wait();
66+
application.StartAsync(new SampleServer()).Wait();
6767

6868
// run the application interactively.
6969
Application.Run(new SampleClientForm(application, null, application.ApplicationConfiguration));

Samples/Client.Net4/UA Sample Client.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
<Version>9.0.6</Version>
139139
</PackageReference>
140140
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Bindings.Https">
141-
<Version>1.5.376.244</Version>
141+
<Version>1.5.377.5-preview</Version>
142142
</PackageReference>
143143
<PackageReference Include="System.Net.Http">
144144
<Version>4.3.4</Version>

Samples/ClientControls.Net4/UA Client Controls.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,16 +1015,16 @@
10151015
</ItemGroup>
10161016
<ItemGroup>
10171017
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Core">
1018-
<Version>1.5.376.244</Version>
1018+
<Version>1.5.377.5-preview</Version>
10191019
</PackageReference>
10201020
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Client">
1021-
<Version>1.5.376.244</Version>
1021+
<Version>1.5.377.5-preview</Version>
10221022
</PackageReference>
10231023
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Client.ComplexTypes">
1024-
<Version>1.5.376.244</Version>
1024+
<Version>1.5.377.5-preview</Version>
10251025
</PackageReference>
10261026
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Configuration">
1027-
<Version>1.5.376.244</Version>
1027+
<Version>1.5.377.5-preview</Version>
10281028
</PackageReference>
10291029
</ItemGroup>
10301030
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

Samples/Controls.Net4/ClientForm.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ private async void PerformanceTestMI_Click(object sender, EventArgs e)
368368
new PerformanceTestDlg().ShowDialog(
369369
m_configuration,
370370
m_endpoints,
371-
await m_configuration.SecurityConfiguration.ApplicationCertificate.Find(true));
371+
await m_configuration.SecurityConfiguration.ApplicationCertificate.FindAsync(true));
372372
}
373373
catch (Exception exception)
374374
{

Samples/Controls.Net4/Common/DataEncodingDlg.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
using Opc.Ua.Client;
4040
using Opc.Ua.Client.Controls;
41+
using Opc.Ua.Client.ComplexTypes;
4142

4243
namespace Opc.Ua.Sample.Controls
4344
{

Samples/Controls.Net4/Sessions/CreateSecureChannelDlg.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ private async void OkBTN_Click(object sender, EventArgs e)
122122
m_configuration,
123123
m_endpoints[EndpointCB.SelectedIndex],
124124
configuration,
125-
await m_configuration.SecurityConfiguration.ApplicationCertificate.Find(true),
125+
await m_configuration.SecurityConfiguration.ApplicationCertificate.FindAsync(true),
126126
m_messageContext);
127127

128128
// create the channel.

Samples/Controls.Net4/Sessions/SessionOpenDlg.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ private void Open(object state)
260260
session.Open(sessionName, (uint)session.SessionTimeout, identity, preferredLocales, checkDomain ?? true);
261261

262262
var typeSystemLoader = new ComplexTypeSystem(session);
263-
typeSystemLoader.Load().Wait();
263+
typeSystemLoader.LoadAsync().AsTask().GetAwaiter().GetResult();
264264

265265
OpenComplete(null);
266266
}

Samples/Controls.Net4/Sessions/SessionTreeCtrl.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
using Opc.Ua.Client.Controls;
3838
using System.Security.Cryptography.X509Certificates;
3939
using System.Threading.Tasks;
40+
using System.Threading;
4041

4142
namespace Opc.Ua.Sample.Controls
4243
{
@@ -204,7 +205,7 @@ public async Task<Session> Connect(ConfiguredEndpoint endpoint)
204205
throw ServiceResultException.Create(StatusCodes.BadConfigurationError, "ApplicationCertificate must be specified.");
205206
}
206207

207-
clientCertificate = await m_configuration.SecurityConfiguration.ApplicationCertificate.Find(true);
208+
clientCertificate = await m_configuration.SecurityConfiguration.ApplicationCertificate.FindAsync(true);
208209

209210
if (clientCertificate == null)
210211
{
@@ -214,7 +215,7 @@ public async Task<Session> Connect(ConfiguredEndpoint endpoint)
214215
// load certificate chain
215216
clientCertificateChain = new X509Certificate2Collection(clientCertificate);
216217
List<CertificateIdentifier> issuers = new List<CertificateIdentifier>();
217-
await m_configuration.CertificateValidator.GetIssuers(clientCertificate, issuers);
218+
await m_configuration.CertificateValidator.GetIssuersAsync(clientCertificate, issuers);
218219
for (int i = 0; i < issuers.Count; i++)
219220
{
220221
clientCertificateChain.Add(issuers[i].Certificate);
@@ -1369,7 +1370,7 @@ private void SetLocaleMI_Click(object sender, EventArgs e)
13691370
}
13701371

13711372
PreferredLocales = new string[] { locale };
1372-
session.ChangePreferredLocales(new StringCollection(PreferredLocales));
1373+
session.ChangePreferredLocalesAsync(new StringCollection(PreferredLocales), CancellationToken.None);
13731374
}
13741375
catch (Exception exception)
13751376
{

Samples/Controls.Net4/UA Sample Controls.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -707,8 +707,11 @@
707707
</None>
708708
</ItemGroup>
709709
<ItemGroup>
710+
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Client.ComplexTypes">
711+
<Version>1.5.377.5-preview</Version>
712+
</PackageReference>
710713
<PackageReference Include="OPCFoundation.NetStandard.Opc.Ua.Server">
711-
<Version>1.5.376.244</Version>
714+
<Version>1.5.377.5-preview</Version>
712715
</PackageReference>
713716
</ItemGroup>
714717
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

Samples/GDS/Client/Controls/ApplicationCertificateControl.cs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public async Task Initialize(
100100
id.StoreType = CertificateStoreIdentifier.DetermineStoreType(id.StorePath);
101101
id.SubjectName = application.CertificateSubjectName.Replace("localhost", Utils.GetHostName());
102102

103-
certificate = await id.Find(true);
103+
certificate = await id.FindAsync(true);
104104
}
105105
}
106106
}
@@ -131,7 +131,7 @@ public async Task Initialize(
131131
SubjectName = "CN=" + url.DnsSafeHost
132132
};
133133

134-
certificate = await id.Find();
134+
certificate = await id.FindAsync();
135135
}
136136
}
137137
}
@@ -170,31 +170,31 @@ private async void RequestNewButton_Click(object sender, EventArgs e)
170170
{
171171
if (m_application.RegistrationType == RegistrationType.ServerPush)
172172
{
173-
RequestNewCertificatePushMode(sender, e);
173+
RequestNewCertificatePushMode(sender, e).GetAwaiter().GetResult();
174174
}
175175
else
176176
{
177177
await RequestNewCertificatePullMode(sender, e);
178178
}
179179
}
180180

181-
private void RequestNewCertificatePushMode(object sender, EventArgs e)
181+
private async Task RequestNewCertificatePushMode(object sender, EventArgs e)
182182
{
183183
try
184184
{
185-
NodeId trustListId = m_gds.GetTrustList(m_application.ApplicationId, NodeId.Null);
186-
var trustList = m_gds.ReadTrustList(trustListId);
187-
bool applyChanges = m_server.UpdateTrustList(trustList);
185+
NodeId trustListId = await m_gds.GetTrustListAsync(m_application.ApplicationId, NodeId.Null);
186+
var trustList = await m_gds.ReadTrustListAsync(trustListId);
187+
bool applyChanges = await m_server.UpdateTrustListAsync(trustList);
188188

189189
byte[] unusedNonce = new byte[0];
190-
byte[] certificateRequest = m_server.CreateSigningRequest(
190+
byte[] certificateRequest = await m_server.CreateSigningRequestAsync(
191191
NodeId.Null,
192192
m_server.ApplicationCertificateType,
193193
string.Empty,
194194
false,
195195
unusedNonce);
196196
var domainNames = m_application.GetDomainNames(m_certificate);
197-
NodeId requestId = m_gds.StartSigningRequest(
197+
NodeId requestId = await m_gds.StartSigningRequestAsync(
198198
m_application.ApplicationId,
199199
NodeId.Null,
200200
NodeId.Null,
@@ -236,7 +236,7 @@ private async Task RequestNewCertificatePullMode(object sender, EventArgs e)
236236
StorePath = m_application.CertificateStorePath,
237237
SubjectName = Utils.ReplaceDCLocalhost(m_application.CertificateSubjectName)
238238
};
239-
m_certificate = await id.Find(true);
239+
m_certificate = await id.FindAsync(true);
240240
//test if private key is available & exportable, else create new temporary certificate for csr
241241
if (m_certificate != null &&
242242
m_certificate.HasPrivateKey)
@@ -246,7 +246,7 @@ private async Task RequestNewCertificatePullMode(object sender, EventArgs e)
246246
//this line fails with a CryptographicException if export of private key is not allowed
247247
_ = m_certificate.GetRSAPrivateKey().ExportParameters(true);
248248
//proceed with a CSR using the exportable private key
249-
m_certificate = await id.LoadPrivateKey(m_certificatePassword);
249+
m_certificate = await id.LoadPrivateKeyAsync(m_certificatePassword);
250250
}
251251
catch
252252
{
@@ -276,14 +276,14 @@ private async Task RequestNewCertificatePullMode(object sender, EventArgs e)
276276
if (m_certificate == null)
277277
{
278278
// no private key
279-
requestId = m_gds.StartNewKeyPairRequest(
279+
requestId = m_gds.StartNewKeyPairRequestAsync(
280280
m_application.ApplicationId,
281281
NodeId.Null,
282282
NodeId.Null,
283283
Utils.ReplaceDCLocalhost(m_application.CertificateSubjectName),
284284
domainNames,
285285
"PFX",
286-
m_certificatePassword);
286+
m_certificatePassword).GetAwaiter().GetResult();
287287
}
288288
else
289289
{
@@ -296,7 +296,7 @@ private async Task RequestNewCertificatePullMode(object sender, EventArgs e)
296296
{
297297
string absoluteCertificatePrivateKeyPath = Utils.GetAbsoluteFilePath(m_application.CertificatePrivateKeyPath, true, false, false);
298298
byte[] pkcsData = File.ReadAllBytes(absoluteCertificatePrivateKeyPath);
299-
if (m_application.GetPrivateKeyFormat(m_server?.GetSupportedKeyFormats()) == "PFX")
299+
if (m_application.GetPrivateKeyFormat(m_server?.GetSupportedKeyFormatsAsync().GetAwaiter().GetResult()) == "PFX")
300300
{
301301
csrCertificate = X509PfxUtils.CreateCertificateFromPKCS12(pkcsData, m_certificatePassword);
302302
}
@@ -306,7 +306,7 @@ private async Task RequestNewCertificatePullMode(object sender, EventArgs e)
306306
}
307307
}
308308
byte[] certificateRequest = CertificateFactory.CreateSigningRequest(csrCertificate, domainNames);
309-
requestId = m_gds.StartSigningRequest(m_application.ApplicationId, NodeId.Null, NodeId.Null, certificateRequest);
309+
requestId = m_gds.StartSigningRequestAsync(m_application.ApplicationId, NodeId.Null, NodeId.Null, certificateRequest).GetAwaiter().GetResult();
310310
}
311311

312312
m_application.CertificateRequestId = requestId.ToString();
@@ -365,12 +365,12 @@ private async void CertificateRequestTimer_Tick(object sender, EventArgs e)
365365
// in this case, privateKey is null
366366
if (privateKeyPFX == null)
367367
{
368-
X509Certificate2 oldCertificate = await cid.Find(true);
368+
X509Certificate2 oldCertificate = await cid.FindAsync(true);
369369
if (oldCertificate != null && oldCertificate.HasPrivateKey)
370370
{
371-
oldCertificate = await cid.LoadPrivateKey(string.Empty);
371+
oldCertificate = await cid.LoadPrivateKeyAsync(string.Empty);
372372
newCert = CertificateFactory.CreateCertificateWithPrivateKey(newCert, m_temporaryCertificateCreated ? m_certificate : oldCertificate);
373-
await store.Delete(oldCertificate.Thumbprint);
373+
await store.DeleteAsync(oldCertificate.Thumbprint);
374374
}
375375
else
376376
{
@@ -382,7 +382,7 @@ private async void CertificateRequestTimer_Tick(object sender, EventArgs e)
382382
newCert = new X509Certificate2(privateKeyPFX, string.Empty, X509KeyStorageFlags.Exportable);
383383
newCert = CertificateFactory.Load(newCert, true);
384384
}
385-
await store.Add(newCert);
385+
await store.AddAsync(newCert);
386386
if (m_temporaryCertificateCreated)
387387
{
388388
m_certificate.Dispose();
@@ -423,7 +423,7 @@ private async void CertificateRequestTimer_Tick(object sender, EventArgs e)
423423
}
424424

425425
// if we provided a PFX or P12 with the private key, we need to merge the new cert with the private key
426-
if (m_application.GetPrivateKeyFormat(m_server?.GetSupportedKeyFormats()) == "PFX")
426+
if (m_application.GetPrivateKeyFormat(m_server?.GetSupportedKeyFormatsAsync().GetAwaiter().GetResult()) == "PFX")
427427
{
428428
string absoluteCertificatePrivateKeyPath = Utils.GetAbsoluteFilePath(m_application.CertificatePrivateKeyPath, true, false, false) ?? m_application.CertificatePrivateKeyPath;
429429
file = new FileInfo(absoluteCertificatePrivateKeyPath);
@@ -471,10 +471,10 @@ private async void CertificateRequestTimer_Tick(object sender, EventArgs e)
471471
foreach (byte[] issuerCertificate in issuerCertificates)
472472
{
473473
X509Certificate2 x509 = new X509Certificate2(issuerCertificate);
474-
X509Certificate2Collection certs = await store.FindByThumbprint(x509.Thumbprint);
474+
X509Certificate2Collection certs = await store.FindByThumbprintAsync(x509.Thumbprint);
475475
if (certs.Count == 0)
476476
{
477-
await store.Add(new X509Certificate2(issuerCertificate));
477+
await store.AddAsync(new X509Certificate2(issuerCertificate));
478478
}
479479
}
480480
}
@@ -492,13 +492,13 @@ private async void CertificateRequestTimer_Tick(object sender, EventArgs e)
492492
}
493493

494494
byte[] unusedPrivateKey = new byte[0];
495-
bool applyChanges = m_server.UpdateCertificate(
495+
bool applyChanges = m_server.UpdateCertificateAsync(
496496
NodeId.Null,
497497
m_server.ApplicationCertificateType,
498498
certificate,
499499
(privateKeyPFX != null) ? "pfx" : String.Empty,
500500
(privateKeyPFX != null) ? privateKeyPFX : unusedPrivateKey,
501-
issuerCertificates);
501+
issuerCertificates).GetAwaiter().GetResult();
502502
if (applyChanges)
503503
{
504504
MessageBox.Show(
@@ -533,7 +533,7 @@ private void ApplyChangesButton_Click(object sender, EventArgs e)
533533
ApplyChangesButton.Enabled = false;
534534
try
535535
{
536-
m_server.ApplyChanges();
536+
m_server.ApplyChangesAsync().GetAwaiter().GetResult();
537537
}
538538
catch (Exception exception)
539539
{
@@ -547,7 +547,7 @@ private void ApplyChangesButton_Click(object sender, EventArgs e)
547547

548548
try
549549
{
550-
m_server.Disconnect();
550+
m_server.DisconnectAsync().GetAwaiter().GetResult();
551551
}
552552
catch (Exception)
553553
{

0 commit comments

Comments
 (0)