HowTo: Generate Certificate for OpenLDAP and using it for certificate authentication.

Posted on

LDAPS Server Certificate Requirements

LDAPS requires a properly formatted X.509 certificate. This certificate lets a OpenLDAP service listen for and automatically accept SSL connections. The server certificate is used for authenticating the OpenLDAP server to the client during the LDAPS setup and for enabling the SSL communication tunnel between the client and the server. As an option, we can also use LDAPS for client authentication.

Having spent quite some time to make a TLS work, I thought this may be usefull to some :

Creating Self CA certificate:

1, Create the  ldapclient-key.pem private key :

openssl genrsa -des3 -out ldapclient-key.pem 1024

2, Create the ldapserver-cacerts.pem certificate :

openssl req -new -key ldapclient-key.pem -x509 -days 1095 -out ldapserver-cacerts.pem

Creating a certificate for server:

1, Create the ldapserver-key.pem private key

openssl genrsa -out ldapserver-key.pem

2, Create a server.csr certificate request:

openssl req -new -key ldapserver-key.pem -out server.csr

3, Create the ldapserver-cert.pem certificate signed by your own CA :

openssl x509 -req -days 2000 -in server.csr -CA ldapserver-cacerts.pem -CAkey ldapclient-key.pem -CAcreateserial -out ldapserver-cert.pem

4, Create CA copy for the client:

cp -rpf ldapserver-cacerts.pem   ldapclient-cacerts.pem

Now configure the certificates in slapd.conf, the correct files must be copied on each server:

TLSCACertificateFile /etc/openldap/certs/ldapserver-cacerts.pem
TLSCertificateFile /etc/openldap/certs/ldapserver-cert.pem
TLSCertificateKeyFile /etc/openldap/certs/ldapserver-key.pem
TLSCipherSuite HIGH:MEDIUM:+SSLv2

# personnally, I only check servers from client.
# If you do, add this :
TLSVerifyClient never

Configure certificate for ldap clients

Key : ldapclient-key.pem
Crt : ldapclient-cert.pem

HowTo: Manage Sudo users commands and previleges

Posted on

If you want to prevent users from executing a specific command have a look at this.

ssh ALL=(user1) ALL, !/usr/bin/passwd 

Add users and use specific commands

#includedir /etc/sudoers.d

User_Alias JAVATEAM = fileupuser
Cmnd_Alias JUSERCMD =/etc/init.d/tomcat,/usr/bin/tail
JAVATEAM ALL = NOPASSWD : JUSERCMD
User_Alias ADMINTEAM = innouser
Cmnd_Alias SYSTEM =/sbin/service,/usr/sbin/ss,/bin/df,/usr/bin/du,/usr/bin/top,/bin/netstat,/usr/sbin/lsof,/bin/ps,/sbin/chkconfig
Cmnd_Alias FILEM =/bin/zcat,/usr/bin/tail,/bin/cat,/bin/grep
Cmnd_Alias COMPRESS =/usr/bin/unzip,/usr/bin/bzip2,/usr/bin/zip,/bin/tar
ADMINTEAM ALL = NOPASSWD : SYSTEM,FILEM,COMPRESS

this could be understand the logic easily.

Howto: Android_device_enable_rooting

Posted on Updated on

Download packages:

Kingo-compactable devices : http://www.kingoapp.com/android-root/devices.htm

Kingo-ROOT download : http://www.kingoapp.com/index.htm

Step one: Download and install Kingo Android Root into the PC.

ROOT-2

Step two: Enable USB debugging mode on your phone. If it’s running Android 4.0 or 4.1, tap Settings, Developer Options, then tick the box for “USB debugging.” (You may need to switch “Developer options” to On before you can do so.) On Android 4.2, tap Settings, About Phone, Developer Options, and then tick USB debugging.” Then tap OK to approve the setting change.
On Android 4.3 and later (and some versions of 4.2), tap Settings, About Phone, then scroll down to Build Number. Tap it seven times, at which point you should see the message, “You are now a developer!”

Step three: Run Android Root on your PC, then connect your phone via its USB cable. Make sure Device compactable USB driver installed,

ROOT-1

Step four: Click Root and wait for couple of minutes to complete, including the automated reboot at the end.

Howto: Install OpenCV + Apache + Mysql + WSGI with ffmpeg and QT support on Ubuntu 14.04

Posted on Updated on

Install java version “1.7.0_65” and Python 2.7.6 (default, Mar 22 2014, 22:59:56), follow any method
##Update the current installed packages

 sudo apt-get update && sudo apt-get -y upgrade

## To install OpenCV 2.4.2 or 2.4.3 on the Ubuntu 12.04 operating system, first install a developer environment to build OpenCV.

 sudo apt-get install build-essential cmake pkg-config
 sudo apt-get install curl qt-sdk unzip yasm checkinstall build-dep

##Install Image I/O libraries

 sudo apt-get install libjpeg62-dev libtiff4-dev libjasper-dev

##Install the GTK dev library

 sudo apt-get install libgtk2.0-dev

##Install Video I/O libraries

 sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev

##Optional – install support for Firewire video cameras

 sudo apt-get install libdc1394-22-dev

##Install video streaming libraries

 sudo apt-get install libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev

##Install the Python development environment and the Python Numerical library

 sudo apt-get install python-dev python-numpy python-pip
 sudo apt-get install python-opencv python-software-properties python-mysqldb python-xml

##Install the parallel code processing library (the Intel tbb library)

 sudo apt-get install libtbb-dev

##Install the Qt dev library

 sudo apt-get install libqt4-dev

##Install OpenCV Additional support Video/Audio and SSL libraries

 sudo apt-get install zlib1g-dev libssl-dev libreadline-dev libyaml-dev libxml2-dev libxslt1-dev libcurl4-openssl-dev libopencv-dev libmp3lame-dev libopencore-amrnb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils

##Install Apache Server and dependencies

 sudo apt-get install libapache2-mod-wsgi apache2 apache2.2-common apache2-mpm-prefork apache2-utils libexpat1 ssl-cert

##Install Mysql Database Server

 sudo apt-get install mysql-server libmysqlclient-dev

##Installing Python Modules

pip install numpy
pip install pyopencv
pip install Django==1.7.3
pip install django-admin-tools==0.5.2
pip install django-debug-toolbar==1.2.2
pip install django-extensions==1.4.9
pip install ipython==2.3.1
pip install six==1.9.0
pip install sqlparse==0.1.13
pip install wsgiref==0.1.2
pip install MySQL-python==1.2.5

##Download and Extraction OpenCV package

OPENCV_VER=2.4.10
curl "http://fossies.org/linux/misc/opencv-${OPENCV_VER}.zip" -o opencv-${OPENCV_VER}.zip
unzip "opencv-${OPENCV_VER}.zip" && cd "opencv-${OPENCV_VER}"
mkdir build && cd build

##Building OpenCV package from source

cmake -G "Unix Makefiles" -D PYTHON_LIBRARY=/usr/lib/python2.7/config-x86_64-linux-gnu/libpython2.7.so -D CMAKE_BUILD_TYPE=RELEASE -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_FFMPEG=ON -D WITH_OPENGL=ON ..

##Installing OpenCV Package

make -g2 && make install

## Providing Dummy Firewire Video camera device

sudo ln /dev/null /dev/raw1394

##Including Additional Library path

echo "/usr/local/lib" >> /etc/ld.so.conf.d/opencv.conf
sudo ldconfig

##SettingUp environmetn variables

echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
PYTHONPATH=/usr/local/lib/python2.7/dist-packages:$PYTHONPATH
JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-amd64
JAVA_BIN=$JAVA_HOME/bin
PATH=$PATH:$JAVA_BIN
export PKG_CONFIG_PATH PYTHONPATH JAVA_BIN JAVA_HOME PATH" >> /etc/profile.d/python_env.sh

## Execution environment variables for the currnet shell

source /etc/profile.d/python_env.sh

##ToVerify

python -c "import cv2; print(cv2.__version__)"
pkg-config --modversion opencv

#Add Vhost for Apache

root@ip-10-184-30-74:~# pip --version #will show the dist-packages path
pip 1.5.4 from /usr/lib/python2.7/dist-packages (python 2.7)
vi /etc/apache2/sites-available/rasberry-pi.planetcure.in.conf

<VirtualHost *:80>
 ServerName rasberry-pi.planetcure.in
 DocumentRoot /opt/web-home/raspberrypi/facecount
 WSGIDaemonProcess rasberry-pi_demo user=anand group=www-data maximum-requests=10000 python-path=/opt/web-home/raspberrypi/facecount:/usr/lib/python2.7/dist-packages
 WSGIScriptAlias / /opt/web-home/raspberrypi/facecount/wsgi.py
WSGIScriptReloading On
WSGIPassAuthorization On
<Directory /opt/web-home/raspberrypi/facecount/>
 <Files wsgi.py>
 Require all granted
 </Files>
 </Directory>
 <Location />
 WSGIProcessGroup rasberry-pi_demo
 </Location>
Alias /static /opt/web-home/raspberrypi/facecount/static-assets/
<Directory /opt/web-home/raspberrypi/facecount/static-assets/>
 Require all granted
 </Directory>
ErrorLog /opt/web-home/raspberrypi/apache_logs/error.log
 # Possible values include: debug, info, notice, warn, error, crit,
 # alert, emerg.
 LogLevel warn
 CustomLog /opt/web-home/raspberrypi/apache_logs/access.log combined
</VirtualHost>
a2ensite rasberry-pi.planetcure.in

Now Restart Apache

service apache restart

Error: ctypes error: libdc1394 error: Failed to initialize libdc1394

Posted on Updated on

Error while importing Open CV in python with django framework , While compiling the application , it thrown the error like below. libdc1394 is a library for controlling camera hardware. It is an optional installation for the OpenCV package which unable to load the hardware for this time

Error :

libdc1394 error: Failed to initialize libdc1394

We don’t need to use camera hardware, is there perhaps a way of compiling without that part of OpenCV or If the server is in VBox/Virtualization system simply enable USB controller.
If it is remote server and we don’t need camera hardware you can create the null link for the IO dev.

 sudo ln /dev/null /dev/raw1394

Error: Fatal Python error: PyEval_AcquireThread: NULL new thread state

Posted on

This might be cause of various issue.

1, mod_wsgi is compiled for a different Python version and/or a different Python installation than the Python virtual environment

2, Python installation it is trying to use at runtime

3, If mod_wsgi and mod_python are both enabled.

In my case, I figured out the third cause. for fixing disabled mod_python because I was running website under wsgi wrapper.

sudo a2dismod python
sudo service apache2 restart

 

Error: Authz_core:error Client Denied by Server Configuration

Posted on Updated on

I have upgraded apache2.2 to 2.3, now a strange error I faced. Existing Apache authorization directives are not working,

I have done a modification that fixed the issue

Error :

[Wed Jan 28 04:29:51.468839 2015] [authz_core:error] [pid 29764:tid 139708675897088] [client 117.247.186.108:46348] AH01630: client denied by server configuration: /opt/web-home/raspberrypi/facecount/static-assets/images/detect.png

This changes the way that access control is declared from

  Order allow, deny
  Allow from all

to :

  Require all granted

his means that the total configuration for a Directory is now something like:

  <Directory /path/to/directory>
    Options FollowSymlinks
    AllowOverride none
    Require all granted
  </Directory>

Restart apache and it’ll all work nicely.