mirror of
https://github.com/OPCFoundation/UA-.NETStandard.git
synced 2026-10-27 04:59:55 +08:00
improve cert handling of sample apps
- create self signed cert on first start (kudos to bouncy castle) - fix path handling in many areas, - ./ or ../ is treated as rooted dir - special %LocalFolder% for UWP apps to allow to write certs in app temp storage - all batch helpers to create certs removed
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
@echo off
|
||||
REM create the app certificate
|
||||
cd /D %~dp0
|
||||
set CERTSTORE=".\OPC Foundation\CertificateStores\MachineDefault"
|
||||
rd /S/Q %CERTSTORE%
|
||||
md %CERTSTORE%
|
||||
..\..\..\Opc.Ua.CertificateGenerator.exe -cmd issue -sp %CERTSTORE% -ks 2048 -an "UA Sample Server" -dn %COMPUTERNAME% -sn "CN=UA Sample Server/DC=%COMPUTERNAME%" -au "urn:%COMPUTERNAME%:OPCFoundation:SampleServer"
|
||||
set CERTSTORE=
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
xmlns="http://opcfoundation.org/UA/SDK/Configuration.xsd"
|
||||
schemaLocation="./Schema/ApplicationConfiguration.xsd"
|
||||
>
|
||||
<ApplicationName>Opc.Ua.SampleServer</ApplicationName>
|
||||
<ApplicationUri>urn:localhost:OPCFoundation:SampleServer</ApplicationUri>
|
||||
<ApplicationName>UA Core Sample Server</ApplicationName>
|
||||
<ApplicationUri>urn:localhost:OPCFoundation:CoreSampleServer</ApplicationUri>
|
||||
<ProductUri>http://opcfoundation.org/UA/SampleServer</ProductUri>
|
||||
<ApplicationType>Server_0</ApplicationType>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<ApplicationCertificate>
|
||||
<StoreType>Directory</StoreType>
|
||||
<StorePath>OPC Foundation/CertificateStores/MachineDefault</StorePath>
|
||||
<SubjectName>UA Sample Server</SubjectName>
|
||||
<SubjectName>UA Core Sample Server</SubjectName>
|
||||
</ApplicationCertificate>
|
||||
|
||||
<!-- Where the issuer certificate are stored (certificate authorities) -->
|
||||
@@ -180,9 +180,8 @@
|
||||
</Extensions>
|
||||
|
||||
<TraceConfiguration>
|
||||
<OutputFilePath>Logs/Opc.Ua.SampleServer.log.txt</OutputFilePath>
|
||||
<OutputFilePath>./Logs/Opc.Ua.SampleServer.log.txt</OutputFilePath>
|
||||
<DeleteOnLoad>true</DeleteOnLoad>
|
||||
<TraceMasks>0</TraceMasks>
|
||||
<!-- Show Only Errors -->
|
||||
<!-- <TraceMasks>1</TraceMasks> -->
|
||||
<!-- Show Only Security and Errors -->
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace NetCoreConsoleServer
|
||||
ApplicationInstance.MessageDlg = new ApplicationMessageDlg();
|
||||
ApplicationInstance application = new ApplicationInstance();
|
||||
|
||||
application.ApplicationName = "UA Sample Server";
|
||||
application.ApplicationName = "UA Core Sample Server";
|
||||
application.ApplicationType = ApplicationType.Server;
|
||||
application.ConfigSectionName = "Opc.Ua.SampleServer";
|
||||
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Create a UA Sample Server cert for OPC UA server
|
||||
#
|
||||
MYHOSTNAME=`echo $HOSTNAME | cut -f1 -d. `
|
||||
echo Create certificate $MYHOSTNAME for UA Sample Server
|
||||
openssl req -newkey rsa:1024 -out cert.crt -keyout cert.key -subj "/DC=$MYHOSTNAME/CN=UA Sample Server" -nodes
|
||||
openssl x509 -days 365 -req -in cert.crt -signkey cert.key -out cert.pem -sha1 -extfile sampleserver.ext
|
||||
openssl pkcs12 -export -in cert.pem -inkey cert.key -out $MYHOSTNAME.pfx -nodes -passout pass:
|
||||
openssl x509 -in cert.pem -out $MYHOSTNAME.der -outform DER
|
||||
openssl x509 -in $MYHOSTNAME.der -inform DER -text
|
||||
rm cert.*
|
||||
rm -rf "./OPC Foundation"
|
||||
mkdir -p "./OPC Foundation/CertificateStores/MachineDefault/certs"
|
||||
mkdir -p "./OPC Foundation/CertificateStores/MachineDefault/private"
|
||||
mv $MYHOSTNAME.der "./OPC Foundation/CertificateStores/MachineDefault/certs"
|
||||
mv $MYHOSTNAME.pfx "./OPC Foundation/CertificateStores/MachineDefault/private"
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
# Extensions to add to a certificate request
|
||||
|
||||
subjectKeyIdentifier=hash
|
||||
subjectAltName=URI:urn:localhost:OPCFoundation:SampleServer
|
||||
authorityKeyIdentifier=critical,keyid,issuer:always
|
||||
basicConstraints = critical, CA:FALSE
|
||||
keyUsage = critical, nonRepudiation, digitalSignature, keyEncipherment, dataEncipherment, keyCertSign
|
||||
extendedKeyUsage = critical, serverAuth, clientAuth
|
||||
Reference in New Issue
Block a user