CoAP and DTLS integration - iot

I have implementation of CoAP (libcoap), and implementation of DTLS (tinyDTLS).
How can I make integration CoAP (libcoap) with DTLS (tinyDTLS)?
I will be grateful for the any advice.

This is now supported fully in libcoap; when you build it with its submodules:
$ git clone https://github.com/obgm/libcoap --recursive
$ cd libcoap
$ ./autogen.sh
$ ./configure --enable-dtls --with-tinydtls --disable-shared --disable-doxygen --disable-manpages
$ make
$ cd examples
$ ./coap-server -A ::1 -k 1234 &
$ ./coap-client 'coaps://[::1]/' -k 1234 -u CoAP
This is a test server made with libcoap (see https://libcoap.net)
Copyright (C) 2010--2016 Olaf Bergmann <bergmann#tzi.org>
(Tested with development version 9184a75a21; I added the --disable-doxygen line at configuration as well because those tools aren't installed here.)

Unfortunately, I don't have enough reputation to place a comment, even though this is not an answer. Here is my attempt to do the exact same thing, using the client-server examples from both libcoap and tinydtls. Feel free to fork the code, and please sumbit a pull request if you figure out why my client and server don't finish their handshake.

Related

IBM Blockchain - Simple Application

Alright, I need to develop a simple application in an IBM Blockchain(starter plan). But I can't get it done, after almost 1 month of trial and error and thousands of tutorials.
So, my case is really simple(I guess):
I have a models.cto file:
namespace com.test.models
/**
* A company asset.
*/
asset Company identified by company_id {
o String company_id
o String document_key
o String document_value
o String name
o String telephone
o String email
}
/**
* A person_in_charge asset.
*/
asset PersonInCharge identified by person_in_charge_id {
o String person_in_charge_id
o String company_id
o String name
o String document_key
o String document_value
o String email
o String language
o String created_date_time
}
I tried to make it as participant instead. I tried to make transaction and then do something with .js file but there are only use cases and tutorials about complex examples using assets, participants, etc. I just want to insert "PersonInCharge" and "Company" separately and query (each Company or by id whatever) also separately.
I was able to made a example using Swagger api generator, but it didn't worked as expected, even thought it created all the methods I wanted, like this:
For summarize, I wanted to deploy my chaincode in a peer, inside of a channel at IBM Blockchain. I did deployed a marble example and it did worked perfectly.
Really self describing error, not with a general message:
I am following a "how to" guide for develop locally and deploy to IBM. Therefore, I am creating a bna file composer archive create -t dir -n . and then creating a card with the downloaded connection settings(from IBM) and else using this tutorial Deploying a business network on Starter Plan
and I am failing at this step: composer network start -c adminCard -n bna-blockchain -V 0.0.1 -A admin -C ./credentials/admin-pub.pem -f delete_me.card. perhaps beucause I'm not being able to instantiate my chaincode on IBM Blockchain.
Sorry if it looks confunsing, just ask me if you have any questions about my issue.
Thanks in advance and any help would be awesome!
Before starting the network, you need to install it:
composer network install -c adminCard -a vehicle-manufacture-network.bna
I took a break in the development and came back after a month. In that time, I had help of a person inside IBM who could help me to get it done.
And I'm here so point out, some failures too.
The IBM guy(I won't say his name, of course) itself said that the service to upload a chaincode(channels/chaincode/Install chaincode) is broken and does not work well.
Also, I asked an easy to answer question in the IBM Blockchain paid forum but had no help at all(they did not even answer the question), even after almost 3 months. And you can't find a tutorial(besides marbles samples) that works from start to end.
Sorry if it looks like I'm raging for nothing in here, but I had a really hard time to put it all together to work 100%.
I will not show how to create a model file or transactional scripts(because there are a plenty of it on examples) but the commands you need to execute in order to run the chaincode on IBM and generate a loopback API. With that said...
Let's go to what's important: the code
First things first, Environment settings:
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.6 LTS
Release: 16.04
Codename: xenial
IMPORTANT: IBM Blockchain(until now 2019-03-23) won't run under virtualized machines like virtual box or hyperv because of a couple npm dependencies. But a hardware virtual machine(HVM) like amazon ones will do just fine.
STEPS
Install node and npm(follow the versions strictly as listed)
node -v
v8.15.1
npm -v
6.4.1
curl -O https://hyperledger.github.io/composer/unstable/prereqs-ubuntu.sh
chmod u+x prereqs-ubuntu.sh
./prereqs-ubuntu.sh
npm install -g --unsafe-perm composer-cli#0.20.5
npm install -g --unsafe-perm composer-rest-server#0.20.5
composer-rest-server -v
v0.20.5
composer -v
v0.20.5
Create a project using hyperledger composer-playground. Export it and navigate through the root directory of the project you just downloaded(the project can be developed locally too).
Download the connection settings file at IBM Blockchain(Overview/Connection Profile/Download) and name it as connection-profile.json. Find the node registrar, you'll use it to create the cards.
Run npm install. If anything goes wrong while installing the dependencies, check if you're using exactly the same versions that I am using. If you're not, uninstall it all and start again from the beginning.
tricky zone
composer card create -f ca.card -p connection-profile.json -u admin -s *your-password*
composer card import -f ca.card -c ca
composer identity request --card ca --path ./credentials -u admin -s *your-password*
You'll see that the credentials folder were generated. Inside this folder, find
the file admin-pub.pem (credentials/admin-pub.pem) copy the whole content of it, and then upload it to IBM Blockchain(Members/Certificates/Add Certificate). You'll be prompted to restart peers, click "yes"
After the peers come back online, in the same Certificates tab, find the certificate you just add, in the ACTION column click at the menu, and then choose the option "Sync Certificate".
composer archive create -t dir -n .
composer card create -f adminCard.card -p connection-profile.json -u admin -c ./credentials/admin-pub.pem -k ./credentials/admin-priv.pem --role PeerAdmin --role ChannelAdmin
composer card import -f ./adminCard.card -c adminCard
composer network install -c adminCard -a bna-name#version.bna
composer network start -c adminCard -n *bna-name* -V *bna-version* -A admin -C ./credentials/admin-pub.pem -f delete_me.card (Output: Successfully created business network card: Filename: delete_me.card)
composer card create -n *bna-name* -p connection-profile.json -u admin -c ./credentials/admin-pub.pem -k ./credentials/admin-priv.pem (Output file: admin#*bna-name*.card)
composer card import -f ./admin#*bna-name*.card (Card file: ./admin#*bna-name*.card Card name: admin#*bna-name*)
Now you'll generate the rest api using (automatically generated using swagger)
composer-rest-server -c admin#*bna-name* -n never -w true -p 8080
Enjoy!

lack MOSQ_1.5 for mosquitto

I am using mosquitto as one of my project tool. After i successfully compile (make binary) mosquitto via source code and try to run mosquitto_sub/pub, its shows that
./mosquitto_sub: /usr/lib/i386-linux-gnu/libmosquitto.so.1: version `MOSQ_1.5' not found (required by ./mosquitto_sub)
while Mosquitto and Mosquitto_psswd is able is run without any problem. Besides, my mosquitto version is 1.5.
I have no idea about this problem.
Any Help appreciated .
It sounds like you have an earlier version of mosquitto installed and it's libraries are on the system path.
Make sure you have uninstalled any earlier versions of mosquitto installed on the machine.
Also make sure you have run make install as root in your build directory to copy the libraries to the correct locations
I had a similar issue building on rpi model B+ using GNU make 4.2.1 and cc (Raspbian 8.3.0-6+rpi1) 8.3.0
Error reported: ./mosquitto_sub: /usr/lib/i386-linux-gnu/libmosquitto.so.1: version `MOSQ_1.6' not found (required by ./mosquitto_sub)
Note: I left the existing distribution in place so that I could leverage off the systemd mosquitto.service that gets installed with the debian packages mosquitto and mosquitto-clients.
Resolution:
mkdir proj
git clone https://github.com/eclipse/mosquitto.conf
cd mosquitto
# my build failed on master branch, so I picked a tag that worked for me
git checkout -b 1.6.9 tags/1.6.9
make WITH_WEBSOCKETS=yes WITH_DOCS=yes WITH_SRV=yes
# overwrite the existing binaries
sudo make install
sudo ldconfig
# verify that the newly installed binaries have overwritten the originals.
mosquitto --help|grep -w 'mosquitto version'
mosquitto_pub --help|grep -w 'mosquitto_pub version'
mosquitto_sub --help|grep -w 'mosquitto_sub version'

How to build LLVM doxygen in HTML ? I tried but failed

I want to get a copy of the doxygen web-pages of llvm, so I can work with it without the internet.
I did as follows:
$ cd LLVM_ROOT_DIR
$ mkdir out
$ cd out/
$ ../configure --enable-doxygen
$ make ENABLE_OPTIMIZED=1
But it only built llvm without documentation. I also tried
$ make BUILD_FOR_WEBSITE=1 ENABLE_OPTIMIZED=1
and
$ make ENABLE_OPTIMIZED=1 EXTRA_DIST=1
All of them did not work.
How could I build the web pages ?
Thanks a lot.
Using recent versions of LLVM, an in-source build is prohibited by configure. Luckily the documentation can be built using cmake.
$ mkdir out
$ cd out/
$ cmake -DLLVM_ENABLE_DOXYGEN=On ../
$ make doxygen-llvm
The process will take a while, but after it you should have the full documentation.
Once you enable doxygen in the configure step, you can run make doxygen-llvm on the docs/ folder in your build directory.
You can run make help to check the available options.
I collect the web-site by wget.

Error installing homebrew on mac (curl: (6) Could not resolve host: raw.githubusercontent.com)

I am trying to following instructions on homebrew homepage but the following
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
returns the following error:
curl: (6) Could not resolve host: raw.githubusercontent.com
Any suggestions?
If you happen to be behind a proxy, You might need a way out, to exit
export http_proxy=http://YOURPROXY:PORT export ALL_PROXY=$http_proxy
For some other users, setting back their github https and https-proxy to default works sometimes as well.
git config --global --unset http.proxy
git config --global --unset https.proxy
I have resolved this by adding a new name server into network configuration.
Click on "System Preferences" then "Network", "Advanced" , "DNS", "+" and enter IP of the new name server, a good public name server is "8.8.8.8" .
You are most probably behind a proxy. Consider running curl command with -k parameter:
-k, --insecure
(SSL) This option explicitly allows curl to perform "insecure" SSL connections and transfers. All
SSL connections are attempted to be made secure by using the CA certificate bundle installed by
default. This makes all connections considered "insecure" fail unless -k, --insecure is used.
See this online resource for further details:
http://curl.haxx.se/docs/sslcerts.html
Check also Homebrew docs where they talk about this.
As others noted, the problem is a proxy blocking access to the download. The "non-hack" solution is...
Disconnect from your personal/company's VPN
Rerun the homebrew installation script
Currently...
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Tried everything,
Finally installing Cloudflare on the machine sorted out the issue.
Follow this: https://developers.cloudflare.com/warp-client/get-started/linux/
If non of the above solutions worked and you can't ping https://github.com/ or any other websites with your terminal ,it is because of an application that monitors and controls the access of network , so make sure that your terminal is not blocked from accessing the network by any Firewalls.
It gave an error on the first attempt. However, it was installed on second attempt. The solution is to retry attempting the call.
Setting proxy with Username, password and port number worked for me
export http_proxy=http://<MacUser>:<MacPass><proxy server>:<ProxyPort>
export https_proxy=http_proxy
After that simply execute
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Experienced the same issue while trying to install home-brew on my Mac M1
Did the following, issue resolved.
Paste this in the terminal and hit enter.
export http_proxy=http://YOURPROXY:PORT export ALL_PROXY=$http_proxy
Now paste the home-brew installation cmd in terminal
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
This will work.
In my case I was running Gananche Blockchain simulation on my machine, once I quit that application I was able to use Homebrew.
I faced this issue recently and I was not sure what is my proxy address and port as nothing was selected under the connection proxy.
Followed this :
Click on "System Preferences" then "Network", on selected connection click "Advanced", then click "proxy"
I simply appended ', *raw.githubusercontent.com*' in text area given for "Bypass proxy settings for these Hosts & Domains:"
It now looks like:
*.local, 169.254/16, raw.githubusercontent.com
Now, retry /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
literally just restart the machine. Worked well for me.
I'm able to solve this issue by cloning the repository to local directory and executing install.sh file manually.
Steps:
git clone https://github.com/Homebrew/install.git
/bin/bash install/install.sh
Thank me later ;)

Why is PHP CodeSniffer Freezing?

I'm a Junior Programmer where I work. Our website was written using PHP 4. We're migrating from PHP 4 to PHP 5.3. There are roughly 5000 PHP files in around 595 directories. So, as you can imagine, the scope of this project is pretty huge.
We use Subversion for version control. I have two separate checkouts. I have two VMs that act as separate webhosts - one stack emulates our actual webserver (CentOS 4, PHP4, etc) and the other is a PHP 5.3 stack (Ubuntu 12.04 LTS).
I took the time to check the files for basic syntax errors using the following commands:
Edit: I ran the following recursive searches from the root of the website.
find ./ -type f -name \*.php -exec php -l {} \; < ~/php5_basic_syntax_assessment.txt
find ./ -type f -name \*.inc -exec php -l {} \; < ~/php5_basic_syntax_inc_assessment.txt
I realize that using php -l to check basic syntax doesn't reveal deprecated code structures/functions and doesn't provide warnings (IE: use preg_slice() instead of slice()). Therefore, I decided to install PHP CodeSniffer.
First, I installed PEAR: [I accepted all the default parameters]
cd ~/
mkdir pear
cd pear
wget http://pear.php.net/go-pear.phar
php go-pear.phar
Next, I installed git:
cd ~/
sudo apt-get update
sudo apt-get install git
Next, I installed PHP Code Sniffer
pear install PHP_CodeSniffer
Finally, I installed the following PHP 5.3 Compatibility standards for the PHP Code Sniffer:
git clone git://github.com/wimg/PHP53Compat_CodeSniffer.git PHP53Compatibility
I did all of the above so that I could assess the 5K PHP files in an automated kind of way. It would be extremely tedious and time consuming to go through each file to make sure they manually follow the PHP 5.3 coding standards.
Finally, here's the command I used to run the PHP Code Sniffer:
phpcs --standard=/home/my_user_name/PHP53Compatibility -p --report-file=/home/my_user_name/php53_assessment.txt /path/to/web/root
To make sure that the specific standards aren't the problem, I also ran the PHP Code Sniffer using the default standards:
phpcs -p --report-file=/home/my_user_name/php53_assessment.txt /path/to/web/root
Either way, the reports freeze in the same place. I've been awake for over 24 hours. I waited for 18 hours before stopping the first run by using CTRL+C. The second is still running and has been running for about an hour and a half.
So, what is causing my PHP Code Sniffer to freeze?
All help is very much appreciated.
Bit late, but I ran into the same issue. Limit the files to just PHP files should do the trick: phpcs -p -- ./**/*.php

Resources