Certificate and AllocateMemory

Set other certificate witouth path. (Testing with Letsencrypt)
AllocateMemory to clean FreeMemory (No more UTF8("String")
This commit is contained in:
René Linder 2020-12-04 21:00:49 +01:00
parent cf94b7bc06
commit f5521f2e39

View file

@ -23,10 +23,10 @@ Define counter, v_lweb_srv_stop
lhs_web::set_config(lhs_web::#conf_HTTP_port, "8081") lhs_web::set_config(lhs_web::#conf_HTTP_port, "8081")
;lhs_web::set_config(lhs_web::#conf_binding, "127.0.0.1") ;lhs_web::set_config(lhs_web::#conf_binding, "127.0.0.1")
lhs_web::set_config(lhs_web::#conf_HTTP_binding, "0.0.0.0") lhs_web::set_config(lhs_web::#conf_HTTP_binding, "0.0.0.0")
lhs_web::set_config(lhs_web::#conf_HTTPS_CA, "/home/renlin/dev/libressl/sample/test_ca.pem") lhs_web::set_config(lhs_web::#conf_HTTPS_CA, "fullchain.pem")
lhs_web::set_config(lhs_web::#conf_HTTPS_Cert, "/home/renlin/dev/libressl/sample/test_server_cert.pem") lhs_web::set_config(lhs_web::#conf_HTTPS_Cert, "cert.pem")
lhs_web::set_config(lhs_web::#conf_HTTPS_Key, "/home/renlin/dev/libressl/sample/test_server_key.pem") lhs_web::set_config(lhs_web::#conf_HTTPS_Key, "privkey.pem")
lhs_web::set_config(lhs_web::#conf_HTTPS_Key_Pass, "test-server-pass") lhs_web::set_config(lhs_web::#conf_HTTPS_Key_Pass, "")
lhs_web::set_config(lhs_web::#conf_HTTPS_Binding, "127.0.0.1") lhs_web::set_config(lhs_web::#conf_HTTPS_Binding, "127.0.0.1")
lhs_web::set_config(lhs_web::#conf_HTTPS_Port, "8444") lhs_web::set_config(lhs_web::#conf_HTTPS_Port, "8444")
lhs_web::set_config(lhs_web::#conf_HTTPS_Enable, "1") lhs_web::set_config(lhs_web::#conf_HTTPS_Enable, "1")
@ -42,7 +42,7 @@ lhs_web::set_config(lhs_web::#conf_cache_enable, "0")
Procedure.s Sample_Header(Map Header.s()) Procedure.s Sample_Header(Map Header.s())
Define *Text Define *Text
Define.s Encoded, ZumSenden, TBD Define.s Encoded, ZumSenden, TBD, Text
NewMap Response.s() NewMap Response.s()
TBD="<div><div><h1>Header</h1></div><br/>"+#CRLF$ TBD="<div><div><h1>Header</h1></div><br/>"+#CRLF$
ResetMap(Header()) ResetMap(Header())
@ -50,7 +50,9 @@ Procedure.s Sample_Header(Map Header.s())
TBD = TBD+"<div>"+MapKey(Header())+" : "+Header()+" </div><br/>"+#CRLF$ TBD = TBD+"<div>"+MapKey(Header())+" : "+Header()+" </div><br/>"+#CRLF$
Wend Wend
*Text = UTF8("<!DOCTYPE html><html><header><title>Alle Client Headers</title></header><body>"+TBD+"</body></html>") Text = "<!DOCTYPE html><html><header><title>Alle Client Headers</title></header><body>"+TBD+"</body></html>"
*Text = AllocateMemory(StringByteLength(Text))
PokeS(*Text, Text)
Encoded = Base64Encoder(*Text, MemorySize(*Text)) Encoded = Base64Encoder(*Text, MemorySize(*Text))
Debug "Encoded: " + Encoded Debug "Encoded: " + Encoded
Response(lhs_web::#cha_R_ResponseContentType) = lhs_web::#response_string Response(lhs_web::#cha_R_ResponseContentType) = lhs_web::#response_string
@ -64,7 +66,7 @@ EndProcedure
Procedure.s Formular_Test(Map Header.s(), ContentData.s) Procedure.s Formular_Test(Map Header.s(), ContentData.s)
Define *Text Define *Text
Define.s Encoded, ZumSenden, TBD Define.s Encoded, ZumSenden, TBD, Text
NewMap Response.s() NewMap Response.s()
TBD="<div><div><h1>FormularPost</h1></div><br/>"+#CRLF$ TBD="<div><div><h1>FormularPost</h1></div><br/>"+#CRLF$
ResetMap(Header()) ResetMap(Header())
@ -73,7 +75,9 @@ Procedure.s Formular_Test(Map Header.s(), ContentData.s)
Wend Wend
Debug "TBD:"+TBD Debug "TBD:"+TBD
Debug "contentData:"+ContentData Debug "contentData:"+ContentData
*Text = UTF8("<!DOCTYPE html><html><header><title>Alle Client Headers</title></header><body>"+TBD+"<hr/><br/><h1>ConentJSON</h1><br/>"+ContentData+"</body></html>") Text = "<!DOCTYPE html><html><header><title>Alle Client Headers</title></header><body>"+TBD+"<hr/><br/><h1>ConentJSON</h1><br/>"+ContentData+"</body></html>"
*Text = AllocateMemory(StringByteLength(Text))
PokeS(*Text, Text)
Debug "Unencoded:"+PeekS(*Text, -1 , #PB_UTF8) Debug "Unencoded:"+PeekS(*Text, -1 , #PB_UTF8)
Encoded = Base64Encoder(*Text, MemorySize(*Text)) Encoded = Base64Encoder(*Text, MemorySize(*Text))
Debug "Encoded: " + Encoded Debug "Encoded: " + Encoded
@ -89,7 +93,7 @@ EndProcedure
Procedure.s Php_Test(Map Header.s(), ContentData.s) Procedure.s Php_Test(Map Header.s(), ContentData.s)
Define *Text, Php Define *Text, Php
Define.s Execute, Phpresult, Encoded, ZumSenden Define.s Execute, Phpresult, Encoded, ZumSenden, Text
NewMap Response.s() NewMap Response.s()
Execute = lhs_web::get_config(lhs_web::#conf_basedir) + Header(lhs_web::#http_head_request) Execute = lhs_web::get_config(lhs_web::#conf_basedir) + Header(lhs_web::#http_head_request)
@ -104,7 +108,9 @@ Procedure.s Php_Test(Map Header.s(), ContentData.s)
Wend Wend
CloseProgram(Php) ; Schließt die Verbindung zum Programm CloseProgram(Php) ; Schließt die Verbindung zum Programm
EndIf EndIf
*Text = UTF8(Phpresult) Text = Phpresult
*Text = AllocateMemory(StringByteLength(Text))
PokeS(*Text, Text)
Debug "Unencoded:"+PeekS(*Text, -1 , #PB_UTF8) Debug "Unencoded:"+PeekS(*Text, -1 , #PB_UTF8)
Encoded = Base64Encoder(*Text, MemorySize(*Text)) Encoded = Base64Encoder(*Text, MemorySize(*Text))
Debug "Encoded: " + Encoded Debug "Encoded: " + Encoded