I wrote a http request code in Termux ... result was certificate verify failed How to fix certificate verify on nim ?
httpreq.nim
import httpclient
var client = newHttpClient()
echo client.getContent("http://google.com")
Compiled
c -r -d:ssl httpreq.nim
result:
/data/data/com.termux/files/home/nimtest/httpreq.nim(5) httpreq
/data/data/com.termux/files/usr/lib/nim/lib/pure/httpclient.nim(1101) getContent
/data/data/com.termux/files/usr/lib/nim/lib/pure/httpclient.nim(1096) get
/data/data/com.termux/files/usr/lib/nim/lib/pure/httpclient.nim(1072) request
/data/data/com.termux/files/usr/lib/nim/lib/pure/httpclient.nim(1048) request
/data/data/com.termux/files/usr/lib/nim/lib/pure/httpclient.nim(998) requestAux
/data/data/com.termux/files/usr/lib/nim/lib/pure/httpclient.nim(890) newConnection
/data/data/com.termux/files/usr/lib/nim/lib/pure/net.nim(802) wrapConnectedSocket
/data/data/com.termux/files/usr/lib/nim/lib/pure/net.nim(914) socketError
/data/data/com.termux/files/usr/lib/nim/lib/pure/net.nim(517) raiseSSLError
[[reraised from: /data/data/com.termux/files/home/nimtest/httpreq.nim(5) httpreq
/data/data/com.termux/files/usr/lib/nim/lib/pure/httpclient.nim(1101) getContent
/data/data/com.termux/files/usr/lib/nim/lib/pure/httpclient.nim(1096) get
/data/data/com.termux/files/usr/lib/nim/lib/pure/httpclient.nim(1072) request
/data/data/com.termux/files/usr/lib/nim/lib/pure/httpclient.nim(1048) request
/data/data/com.termux/files/usr/lib/nim/lib/pure/httpclient.nim(998) requestAux
/data/data/com.termux/files/usr/lib/nim/lib/pure/httpclient.nim(894) newConnection
]]
Error: unhandled exception: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed [SslError]
OK, I clear this issue on Windows.
Rf. https://forum.nim-lang.org/t/7551#47896
I will try as same way on Termux later ...
termux case:
u0_a185@localhost ~/nimtest> curl https://curl.se/ca/cacert.pem -o cacert.pem
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed 100 199k 100 199k 0 0 2363k 0 --:--:-- --:--:-- --:--:-- 2374k u0_a185@localhost ~/nimtest> ls
cacert.pem httpreq httpreq.nim nimtest.nimble src tests
u0_a185@localhost ~/nimtest> nim c -d:ssl httpreq.nim
Hint: used config file '/data/data/com.termux/files/usr/lib/nim/config/nim.cfg' [Conf]
Hint: used config file '/data/data/com.termux/files/usr/lib/nim/config/config.nims' [Conf] ..............................................
Hint: [Link]
Hint: 96470 lines; 3.193s; 75.215MiB peakmem; Debug build; proj: /data/data/com.termux/files/home/nimtest/httpreq.nim; out: /data/data/com.termux/files/home/nimtest/httpreq [SuccessX]
u0_a185@localhost ~/nimtest> ./httpreq
/data/data/com.termux/files/home/nimtest/httpreq.nim(6) httpreq
/data/data/com.termux/files/usr/lib/nim/lib/pure/httpclient.nim(1101) getContent
/data/data/com.termux/files/usr/lib/nim/lib/pure/httpclient.nim(1096) get
/data/data/com.termux/files/usr/lib/nim/lib/pure/httpclient.nim(1072) request
/data/data/com.termux/files/usr/lib/nim/lib/pure/httpclient.nim(1048) request /data/data/com.termux/files/usr/lib/nim/lib/pure/httpclient.nim(998) requestAux
/data/data/com.termux/files/usr/lib/nim/lib/pure/httpclient.nim(890) newConnection
/data/data/com.termux/files/usr/lib/nim/lib/pure/net.nim(802) wrapConnectedSocket
/data/data/com.termux/files/usr/lib/nim/lib/pure/net.nim(914) socketError
/data/data/com.termux/files/usr/lib/nim/lib/pure/net.nim(517) raiseSSLError
[[reraised from:
/data/data/com.termux/files/home/nimtest/httpreq.nim(6) httpreq /data/data/com.termux/files/usr/lib/nim/lib/pure/httpclient.nim(1101) getContent
/data/data/com.termux/files/usr/lib/nim/lib/pure/httpclient.nim(1096) get
/data/data/com.termux/files/usr/lib/nim/lib/pure/httpclient.nim(1072) request
/data/data/com.termux/files/usr/lib/nim/lib/pure/httpclient.nim(1048) request
/data/data/com.termux/files/usr/lib/nim/lib/pure/httpclient.nim(998) requestAux /data/data/com.termux/files/usr/lib/nim/lib/pure/httpclient.nim(894) newConnection ]]
Error: unhandled exception: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed [SslError]
Thank you.
I will wait for updating 'pkg nim'. I 'm very new nim.I started nim 5 h ago.So I should learn another basic syntax on nim first.
I 'm back here.
I learn how to build Nim-1.4.8 on termux
wget https://nim-lang.org/download/nim-1.4.8.tar.xz
tar -vxf nim-1.4.8.tar.xz
cd nim-1.4.8
sh build.sh --os android
bin/nim c koch
./koch boot -d:release
./koch tools
but I don't know how to built nighty version on termux. Is there a good tutorial about building nighty version from source file of Nim on Termux ?
Here is my recipe (last used on June, 18th)
#!/bin/bash
# first time only
# git clone https://github.com/nim-lang/Nim.git
pushd Nim
git stash
git pull https://github.com/nim-lang/Nim.git
# first time
# git clone -q --depth 1 https://github.com/nim-lang/csources.git
if true; then
pushd csources_v1
git stash
git pull -q -f --depth 1 https://github.com/nim-lang/csources_v1.git
popd
patch -p0 < ../nim.cfg.patch
patch -p0 < ../csources.patch
fi
nim r tools/ci_generate.nim
source ./build_all.sh
# ./koch doc --parallelBuild:4
for X in bin/{nim,nim-gdb,nim-gdb.bash,nimgrep,nimsuggest,nimpretty,testament}; do
cp $X $PREFIX/bin
done
./koch install $PREFIX/lib
if false; then
PATH=.:$PATH
./koch doc --parallelBuild:4
fi
popd
with csources.patch :
--- csources_v1/makefile.Orig 2020-11-13 11:48:32.222648732 +0100
+++ csources_v1/makefile 2020-11-13 11:32:31.795701655 +0100
@@ -22,8 +22,14 @@
endif
ifeq ($(uos),linux)
- myos = linux
- LDFLAGS += -ldl -lm
+ los := $(shell sh -c 'uname -o| tr "[:upper:]" "[:lower:]"')
+ ifeq ($(los),android)
+ LDFLAGS += -ldl -lm -landroid-glob -latomic
+ myos = android
+ else
+ LDFLAGS += -ldl -lm
+ myos = linux
+ endif
endif
ifeq ($(uos),dragonfly)
myos = freebsd
@@ -146,6 +152,9 @@
ifeq ($(ucpu),armv7hl)
mycpu = arm
endif
+ifeq ($(ucpu),armv8l)
+ mycpu = arm
+endif
ifeq ($(ucpu),aarch64)
mycpu = arm64
endif
--- csources_v1/build.sh.Orig 2020-11-13 12:50:10.675444931 +0100
+++ csources_v1/build.sh 2020-11-13 12:59:48.691413080 +0100
@@ -71,6 +71,13 @@
# convert to lower case:
ucpu=`echo $ucpu | tr "[:upper:]" "[:lower:]"`
uos=`echo $uos | tr "[:upper:]" "[:lower:]"`
+if [ "$uos" = "linux" ] ; then
+ los=`uname -o`
+ los=`echo $los | tr "[:upper:]" "[:lower:]"`
+ if [ "$los" = "android" ] ; then
+ uosname="android"
+ fi
+fi
uosname=`echo $uosname | tr "[:upper:]" "[:lower:]"`
case $uos in
@@ -121,7 +128,7 @@
*android* )
myos="android"
LINK_FLAGS="$LINK_FLAGS -ldl -lm -lrt"
- LINK_FLAGS="$LINK_FLAGS -landroid-glob"
+ LINK_FLAGS="$LINK_FLAGS -landroid-glob -latomic"
;;
*)
echo 2>&1 "Error: unknown operating system: $uos"
and nim.cfg.patch :
--- config/nim.cfg.Orig 2020-11-12 21:01:55.772997865 +0100
+++ config/nim.cfg 2020-11-12 21:04:01.402997775 +0100
@@ -113,10 +113,10 @@
@if unix:
@if not bsd or haiku:
# -fopenmp
- gcc.options.linker = "-ldl"
- gcc.cpp.options.linker = "-ldl"
- clang.options.linker = "-ldl"
- clang.cpp.options.linker = "-ldl"
+ gcc.options.linker = "-ldl -landroid-glob -latomic"
+ gcc.cpp.options.linker = "-ldl -landroid-glob -latomic"
+ clang.options.linker = "-ldl -landroid-glob -latomic"
+ clang.cpp.options.linker = "-ldl -landroid-glob -latomic"
tcc.options.linker = "-ldl"
@end
@if bsd:
ï¼ HJarausch
Thank you HJarausch ;-)
I'm not special yet. Is that means those bash execute building nightly dev nim from the source ?
Nim Compiler Version 1.6.0 [Android: arm] on termux package is clear this point.
It's mean no problem. just use '-d:ssl' for compiling for use https request on nomal httpclient.