--- a/trunk/mqttsparkplug/mqttsparkplug-example/Device_1/Plc Logic/Application2_1/Edge2/AdditionalStepsToRegisterAClientCertificateWithtest_mosquitto_org/svnobj
+++ b/trunk/mqttsparkplug/mqttsparkplug-example/Device_1/Plc Logic/Application2_1/Edge2/AdditionalStepsToRegisterAClientCertificateWithtest_mosquitto_org/svnobj
@@ -1,84 +1,88 @@
-Gx_lö'!0…jüo Œ M‡¹âÐ
-hSystem.StringL{f8a58466-d7f6-439f-bbb8-d4600e41d099}ImplementationL{3b83b776-fb25-43b8-99f2-3c507c9143fc}TextDocumentL{f3878285-8e4f-490b-bb1b-9acbb7eb04db}TextLinesL{a5de0b0b-1cb5-4913-ac21-9d70293ec00d}	Id
-longTagText
²// This function_block, getClientCert, interacts with CODESYS Runtime's Certificate Store¨// To view the source and documentation, Right click > Browse > Go to definition ...œ// ... then right click SparkplugB."GetClientCert" > Browse > Go to definitionZgetClientCert(xUseCertStore          := TRUE,P              xCreateSelfSigned      :=,P              xCreateCSR             :=,P              xInstallCertFromString :=,P              sCommonName            :=,P              sCountry               :=,P              sOrganization          :=,P              uliValidity            :=,P              sClientCert            :=,P              xProvideCertificate    =>,\              hCert                  => hCert,R              sCSRorClientCertOut    =>);¤// wait a few cycles, incase the getClientCert already finds the right client cert6IF countClientCert > 6 THENb    IF NOT getClientCert.xProvideCertificate THEN ~        //There is no Certificate registered, so generate a CSR!R        getClientCert.xCreateCSR := TRUE;"    END_IF#ELSE$V    countClientCert := countClientCert + 1;%END_IF&D// If xProvideCertificate is set, 'RIF getClientCert.xProvideCertificate THEN(œ    WaitForTheServerToRegisterCert(IN := TRUE, PT := T#1S, Q =>); //1sec timer)X    IF WaitForTheServerToRegisterCert.Q THEN*^        StillGettingClientCertificate := FALSE;+ò(* Below this line is specific to registering a CSR with test.mosquitto.org.  Other servers will have other procedures *),n//We are going to use a HTTP Post to get our CSR signed-BhttpPost := "submit=Submit&csr=";.ú//dirty hack: UTF8toUTF16 also works on strings, if every character is less than 0x80.. STRING_TO_WSTRING only does 255 chars/ //            I know that for BASE64 encoded CSRs, every character is below 0x800¨Stu.ConvertUTF8toUTF16(sourceStart        := ADR(getClientCert.sCSRorClientCertOut),1Ž                       targetStart        := ADR(wsCSRorClientCertOut),2”                       dwTargetBufferSize := SIZEOF(wsCSRorClientCertOut),3h                       bStrictConversion  := FALSE);48//convert the " " to %20 etc5²wsCSRorClientCertOut := Web_CLient.URL_ENCODE_WSTRING(pwIn := ADR(wsCSRorClientCertOut));6¸//add the CSR to the end of the httpPost.  note Standard64.WCONCAT() only works on 255 chars7ìSTU.StrConcatW(pstFrom := ADR(wsCSRorClientCertOut), pstTo := ADR(httpPost), iBufferSize := TO_INT(SIZEOF(httpPost)));8°IF LEN(getClientCert.sCSRorClientCertOut) > 0 AND (getClientCert.xCreateCSR = TRUE) THEN9h    //once a CSR is generated, execute the http Post:B    RegisterCSR.xExecute := TRUE;;œ// This Web_Client.WebClient sends the CSR to test.mosquitto.org to be signed <FRegisterCSR(xExecute            :=,=F            udiTimeOut          :=,>ô            sURL                := 'https://test.mosquitto.org/ssl/index.php', //form for submitting CSRs to mosquitto.org?f            eRequestType        := Web_Client.POST,@˜            eContentType        := Web_Client.CONTENT_TYPE.APPLICATION_FORM,AF            pwsAdditionalHeader :=,Bb            pwsPostValue        := ADR(httpPost),CF            xCloseConnection    :=,DF            hCert               :=,EF            xDone               =>,FF            xBusy               =>,GF            xError              =>,HF            eError              =>,IH            httpResult          =>);J¦// Once signed, we just register the signed version of the certificate in the storeK¼// If the result of the httpPost does not begine with '-----BEGIN' then there was an error ...LX// ... and a CSR was not successfully signedM®IF RegisterCSR.xDone AND (FIND(RegisterCSR.httpResult.sContent, '-----BEGIN') = 1) THENN    //SUCCESSO˜    getClientCert.sClientCert            := RegisterCSR.httpResult.sContent;Pb    getClientCert.xInstallCertFromString := TRUE;QInterfaceRL{a9ed5b7e-75c5-4651-af16-d2c27e98cb94}SMETHOD AdditionalStepsToRegisterAClientCertificateWithtest_mosquitto_orgÐÐÐEPÐÐ	
-­±ÚÐ-
ÐÐ	
-­²ÚÐ-ÐÐ	
-­³ÚÐ-ÐÐ	
-­´ÚÐ-ÐÐ	
-­µÚÐ-ÐÐ	
-­¶ÚÐ-ÐÐ	
-­·ÚÐ-ÐÐ	
-­¸ÚÐ-ÐÐ	
-­¹ÚÐ-ÐÐ	
-­ºÚÐ-ÐÐ	
-­»ÚÐ-ÐÐ	
-­¼ÚÐ-ÐÐ	
-­½ÚÐ-ÐÐ	
-­¾ÚÐ-ÐÐ	
-­¿ÚÐ-ÐÐ	
-­ÀÚÐ-ÐÐ	
-­ÁÚÐ-ÐÐ	
-­ÂÚÐ-ÐÐ	
-­ÃÚÐ-ÐÐ	
-­ÄÚÐ- ÐÐ	
-­ÅÚÐ-!ÐÐ	
-­ÆÚÐ-"ÐÐ	
-­ÇÚÐ-#ÐÐ	
-­ÈÚÐ-$ÐÐ	
-­ÉÚÐ-%ÐÐ	
-­ÊÚÐ-ÐÐ	
-­ËÚÐ-&ÐÐ	
-­ÌÚÐ-'ÐÐ	
-­ÍÚÐ-(ÐÐ	
-­ÎÚÐ-ÐÐ	
-­ÏÚÐ-)ÐÐ	
-­ÐÚÐ-*ÐÐ	
-­ÑÚÐ-"ÐÐ	
-­ÒÚÐ-%ÐÐ	
-­ÓÚÐ-ÐÐ	
-­ÔÚÐ-+ÐÐ	
-­ÕÚÐ-ÐÐ	
-­ÖÚÐ-,ÐÐ	
-­×ÚÐ--ÐÐ	
-­ØÚÐ-.ÐÐ	
-­ÙÚÐ-/ÐÐ	
-­ÚÚÐ-0ÐÐ	
-­ÛÚÐ-1ÐÐ	
-­ÜÚÐ-2ÐÐ	
-­ÝÚÐ-3ÐÐ	
-­ÞÚÐ-ÐÐ	
-­ßÚÐ-4ÐÐ	
-­àÚÐ-5ÐÐ	
-­áÚÐ-6ÐÐ	
-­âÚÐ-7ÐÐ	
-­ãÚÐ-ÐÐ	
-­äÚÐ-8ÐÐ	
-­åÚÐ-9ÐÐ	
-­æÚÐ-:ÐÐ	
-­çÚÐ-%ÐÐ	
-­èÚÐ-ÐÐ	
-­éÚÐ-;ÐÐ	
-­êÚÐ-<ÐÐ	
-­ëÚÐ-=ÐÐ	
-­ìÚÐ->ÐÐ	
-­íÚÐ-?ÐÐ	
-­îÚÐ-@ÐÐ	
-­ïÚÐ-AÐÐ	
-­ðÚÐ-BÐÐ	
-­ñÚÐ-CÐÐ	
-­òÚÐ-DÐÐ	
-­óÚÐ-EÐÐ	
-­ôÚÐ-FÐÐ	
-­õÚÐ-GÐÐ	
-­öÚÐ-HÐÐ	
-­÷ÚÐ-IÐÐ	
-­øÚÐ-ÐÐ	
-­ùÚÐ-JÐÐ	
-­úÚÐ-KÐÐ	
-­ûÚÐ-LÐÐ	
-­üÚÐ-MÐÐ	
-­ýÚÐ-NÐÐ	
-­þÚÐ-OÐÐ	
-­ÿÚÐ-PÐÐ	
-­¸ÚÐ-%ÐQRÐEÐÐ	
-­ÚÐ-S
\ No newline at end of file
+Gx_lÈ'!0…jüo‡¥šR‘ØnQFSystem.StringL{f8a58466-d7f6-439f-bbb8-d4600e41d099}ImplementationL{3b83b776-fb25-43b8-99f2-3c507c9143fc}TextDocumentL{f3878285-8e4f-490b-bb1b-9acbb7eb04db}TextLinesL{a5de0b0b-1cb5-4913-ac21-9d70293ec00d}	Id
+longTagText
²// This function_block, getClientCert, interacts with CODESYS Runtime's Certificate Store¨// To view the source and documentation, Right click > Browse > Go to definition ...œ// ... then right click SparkplugB."GetClientCert" > Browse > Go to definitionJgetClientCert( xUseCertStore := TRUE,H               xCreateSelfSigned :=,:               xCreateCSR :=,R               xInstallCertFromString :=,<               sCommonName :=,6               sCountry :=,@               sOrganization :=,<               uliValidity :=,<               sClientCert :=,L               xProvideCertificate =>,<               hCert => hCert,P               sCSRorClientCertOut => );¤// wait a few cycles, incase the getClientCert already finds the right client cert6IF countClientCert > 6 THENb    IF NOT getClientCert.xProvideCertificate THEN ~        //There is no Certificate registered, so generate a CSR!R        getClientCert.xCreateCSR := TRUE;"    END_IF#ELSE$V    countClientCert := countClientCert + 1;%END_IF&D// If xProvideCertificate is set, 'RIF getClientCert.xProvideCertificate THEN(^    WaitForTheServerToRegisterCert( IN := TRUE,)^                                    PT := T#1S,*p                                    Q => ); //1sec timer+X    IF WaitForTheServerToRegisterCert.Q THEN,^        StillGettingClientCertificate := FALSE;-ò(* Below this line is specific to registering a CSR with test.mosquitto.org.  Other servers will have other procedures *).n//We are going to use a HTTP Post to get our CSR signed/BhttpPost := "submit=Submit&csr=";0ú//dirty hack: UTF8toUTF16 also works on strings, if every character is less than 0x80.. STRING_TO_WSTRING only does 255 chars1 //            I know that for BASE64 encoded CSRs, every character is below 0x802 Stu.ConvertUTF8toUTF16( sourceStart := ADR( getClientCert.sCSRorClientCertOut ),3†                        targetStart := ADR( wsCSRorClientCertOut ),4š                        dwTargetBufferSize := SIZEOF( wsCSRorClientCertOut ),5j                        bStrictConversion := FALSE );68//convert the " " to %20 etc7ºwsCSRorClientCertOut := Web_CLient.URL_ENCODE_WSTRING( pwIn := ADR( wsCSRorClientCertOut ) );8¸//add the CSR to the end of the httpPost.  note Standard64.WCONCAT() only works on 255 chars9nSTU.StrConcatW( pstFrom := ADR( wsCSRorClientCertOut ),:R                pstTo := ADR( httpPost ),;|                iBufferSize := TO_INT( SIZEOF( httpPost ) ) );<´IF LEN( getClientCert.sCSRorClientCertOut ) > 0 AND (getClientCert.xCreateCSR = TRUE) THEN=h    //once a CSR is generated, execute the http Post>B    RegisterCSR.xExecute := TRUE;?œ// This Web_Client.WebClient sends the CSR to test.mosquitto.org to be signed @2RegisterCSR( xExecute :=,A6             udiTimeOut :=,BØ             sURL := 'https://test.mosquitto.org/ssl/index.php', //form for submitting CSRs to mosquitto.orgCZ             eRequestType := Web_Client.POST,DŒ             eContentType := Web_Client.CONTENT_TYPE.APPLICATION_FORM,EH             pwsAdditionalHeader :=,FZ             pwsPostValue := ADR( httpPost ),GB             xCloseConnection :=,H,             hCert :=,I,             xDone =>,J,             xBusy =>,K.             xError =>,L.             eError =>,M:             httpResult => );N¦// Once signed, we just register the signed version of the certificate in the storeO¼// If the result of the httpPost does not begine with '-----BEGIN' then there was an error ...PX// ... and a CSR was not successfully signedQ€IF RegisterCSR.xDone AND (FIND( RegisterCSR.httpResult.sContent,Rp                                '-----BEGIN' ) = 1) THENS    //SUCCESST‚    getClientCert.sClientCert := RegisterCSR.httpResult.sContent;Ub    getClientCert.xInstallCertFromString := TRUE;VInterfaceWL{a9ed5b7e-75c5-4651-af16-d2c27e98cb94}XMETHOD AdditionalStepsToRegisterAClientCertificateWithtest_mosquitto_orgÐÐÐETÐÐ	
+­ÚÐ-
ÐÐ	
+­ÚÐ-ÐÐ	
+­ÚÐ-ÐÐ	
+­ÚÐ-ÐÐ	
+­ÚÐ-ÐÐ	
+­ÚÐ-ÐÐ	
+­ÚÐ-ÐÐ	
+­ÚÐ-ÐÐ	
+­ÚÐ-ÐÐ	
+­	ÚÐ-ÐÐ	

+ÚÐ-ÐÐ	
+­ÚÐ-ÐÐ	
+­ÚÐ-ÐÐ	

ÚÐ-ÐÐ	
+­ÚÐ-ÐÐ	
+­ÚÐ-ÐÐ	
+­ÚÐ-ÐÐ	
+­ÚÐ-ÐÐ	
+­ÚÐ-ÐÐ	
+­ÚÐ- ÐÐ	
+­ÚÐ-!ÐÐ	
+­ÚÐ-"ÐÐ	
+­ÚÐ-#ÐÐ	
+­ÚÐ-$ÐÐ	
+­ÚÐ-%ÐÐ	
+­ÚÐ-ÐÐ	
+­ÚÐ-&ÐÐ	
+­ÚÐ-'ÐÐ	
+­ÚÐ-(ÐÐ	
+­ÚÐ-)ÐÐ	
+­ÚÐ-*ÐÐ	
+­ÚÐ-ÐÐ	
+­ ÚÐ-+ÐÐ	
+­!ÚÐ-,ÐÐ	
+­"ÚÐ-"ÐÐ	
+­#ÚÐ-%ÐÐ	
+­$ÚÐ-ÐÐ	
+­%ÚÐ--ÐÐ	
+­&ÚÐ-.ÐÐ	
+­'ÚÐ-/ÐÐ	
+­(ÚÐ-0ÐÐ	
+­)ÚÐ-1ÐÐ	
+­*ÚÐ-2ÐÐ	
+­+ÚÐ-3ÐÐ	
+­,ÚÐ-4ÐÐ	
+­-ÚÐ-5ÐÐ	
+­.ÚÐ-ÐÐ	
+­/ÚÐ-6ÐÐ	
+­0ÚÐ-7ÐÐ	
+­1ÚÐ-8ÐÐ	
+­2ÚÐ-9ÐÐ	
+­3ÚÐ-:ÐÐ	
+­4ÚÐ-;ÐÐ	
+­5ÚÐ-ÐÐ	
+­6ÚÐ-<ÐÐ	
+­7ÚÐ-=ÐÐ	
+­8ÚÐ->ÐÐ	
+­9ÚÐ-%ÐÐ	
+­:ÚÐ-ÐÐ	
+­;ÚÐ-?ÐÐ	
+­<ÚÐ-@ÐÐ	
+­=ÚÐ-AÐÐ	
+­>ÚÐ-BÐÐ	
+­?ÚÐ-CÐÐ	
+­@ÚÐ-DÐÐ	
+­AÚÐ-EÐÐ	
+­BÚÐ-FÐÐ	
+­CÚÐ-GÐÐ	
+­DÚÐ-HÐÐ	
+­EÚÐ-IÐÐ	
+­FÚÐ-JÐÐ	
+­GÚÐ-KÐÐ	
+­HÚÐ-LÐÐ	
+­IÚÐ-MÐÐ	
+­JÚÐ-ÐÐ	
+­KÚÐ-NÐÐ	
+­LÚÐ-OÐÐ	
+­MÚÐ-PÐÐ	
+­NÚÐ-QÐÐ	
+­OÚÐ-RÐÐ	
+­PÚÐ-SÐÐ	
+­QÚÐ-TÐÐ	
+­RÚÐ-UÐÐ	
+­¸ÚÐ-%ÐVWÐEÐÐ	
+­ÚÐ-X
\ No newline at end of file