- 环境准备
apt-get install -y git gcc autoconf
- 配置hosts文件
vim /etc/hosts
192.30.255.112 github.com git
185.31.16.184 github.global.ssl.fastly.net
- 代码下载
git clone https://github.com/authmillenon/libcoap.git
- git clone报错解决
:gnutls_handshake() failed: The TLS connection was non-properly terminated.
重置代理解决:
git config --global --unset https.https://github.com.proxy
git config --global --unset http.https://github.com.proxy
准备openssl环境
- 下载与解压
wget https://www.openssl.org/source/openssl-1.1.0f.tar.gz
tar -xzf openssl-1.1.0f.tar.gz
- 编译与安装
cd openssl-1.1.0f
./config
make
make install
- 创建链接至lib
ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/ssl/include/openssl /usr/include/openssl
echo “/usr/local/openssl/lib”>>/etc/ld.so.conf
ldconfig -v
openssl version –a
ln -s /usr/local/lib64/libssl.so.1.1 /usr/lib
ln -s /usr/local/lib64/libcrypto.so.1.1 /usr/lib
ln -s /usr/local/bin/openssl /usr/bin/openssl_latest
cd /usr/bin/
mv openssl openssl_old
mv openssl_latest openssl
openssl version
编译libcoap
cd libcoap
./autogen.sh
autoconf
./configure --prefix=$(pwd)/Linux --disable-manpages --disable-doxygen
make
make install
命令使用
cd /root/git-openssl/libcoap/examples
./coap-client -u authId@tenant-k secretkey -m POST coaps://172.26.0.11:16684/event -t application/json -e '{"temp": 5}'
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)