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:
Martin Regen
2016-12-07 18:29:24 +01:00
parent 07b70aeae0
commit 2148d65084
42 changed files with 642 additions and 305 deletions
@@ -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