Saturday, February 23, 2013

Signing code with a digital certificate on Windows 7

First, download and install Windows 7 SDK if you did not get it yet.

Create an 'info' file "cert.info" to be used by the Microsoft' certificate request utility.
It is a simple text file with content like


[NewRequest]
Subject = "CN=pixamba.com"
Exportable = FALSE
KeyLength = 4096


Some more optional fields are shown here, but you probably do not need them.
Next, open cmd.exe and run there Microsoft' request generation tool:

certreq -new cert.inf cert.req

Upload content of "cert.req" file to your CA server and get a valid certificate for your certificate'  request. How you do it depends on what third party CA you are using.
Providing your CA with a valid certificate request file you should get back from them a valid code signing certificate, either as a file or as text which you copy & save into a e.g. "cert.cer" file.

Once you have received or created such a "cert.cer" file, you run the following command on your Windows machine, forcing it to accept the new certificate:

certreq -accept cert.cer

 Next, run the following command:

"C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\signtool.exe" sign  /v /tr "http://www.startssl.com/timestamp"  mysoftware.exe

- where "mysoftware.exe" is the binary you are willing to sign

Note, that you might have some other (probably old and expired) certificates installed on your machine. In this case you will get the following error message:

SignTool Error: Multiple certificates were found that meet all the given
        criteria. Use the /a option to allow SignTool to choose the best
        certificate automatically or use the /sha1 option with the hash of the
        desired certificate.


If the last certificate you just installed is the only valid certificate you can use simply add "/a" option and signtool will automatically selected. If you have multiple valid certificates installed, tell signtool which one you are willing to use with "/sha1" option and the certificate's hash (printed to the standard output by signtool).

So your final command will probably look like this:
"C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\signtool.exe" sign  /a /v /tr "http://www.startssl.com/timestamp"  mysoftware.exe

This should do the signing, giving you the valid output

Number of files successfully Signed: 1
Number of warnings: 0
Number of errors: 0


I am still looking for the information how it can be done on Windows 8 since Windows 7 SDK installation there fails with errors in the middle and there is no signtool utility in any other location on my Windows 8 machine.

Friday, February 08, 2013

Netbeans freezes up on SVN commit: SOLVED

My Netbenas froze up each time I tried to do a SVN commit.
I found the solution here: https://netbeans.org/bugzilla/show_bug.cgi?id=170770

The problem was simple: NetBeans tried to open the commit dialog in some screen location which it can not access (probably because I am switching between different sets of home and office monitors).

So go to the NB-SVN config file and remove the line defining the commit dialog location. In my case the file is located here:

C:\Users\david\AppData\Roaming\NetBeans\7.2.1\config\Preferences\org\netbeans\modules\

Delete the following line:
svn.commit.dialog=2555.0#179.0#607.0#515.0

- and everything is back to work.

Friday, January 11, 2013

Mail delivery failed while sending to hotmail.com addresses

My server was getting "Mail delivery failed" error while sending emails to Hotmail addresses

SMTP error from remote mail server after MAIL FROM: SIZE=3216:
    host mx1.hotmail.com [65.54.188.72]: 550 SC-001 (BAY0-MC1-F41) Unfortunately, messages from 72.55.188.12 weren't sent. Please contact your Internet service provider since part of their network is on our block list. You can also refer your provider to http://mail.live.com/mail/troubleshooting.aspx#errors.


It's hard to understand what to do next since there is no visible service for Hotmail. After some digging I found  this online form on Microsoft Support site:
https://support.msn.com/eform.aspx?productKey=edfsesc&ct=eformts

Filled it up. Do not know if the issue will be solved, but at least they ask all the right questions there :)

Friday, December 28, 2012

Linux: Killing multiple similar processes all together

kill -9 `ps -ef | grep /libexec/abrt | grep -v grep | awk '{print $2}'`

kill all processes that have "/libexec/abrt" in their run path. Do not kill grep command since it will be alos included into the output.

Saturday, December 15, 2012

Linux: Remove all JPG files older than 5 days

 find . -name *.jpg -mtime +5 -print -exec rm {} \;

# starting from the current directory
# also print the file path

# note spaces around rm and {}

Saturday, December 08, 2012

How To Install ffmpeg on CentOs 6.x (6.3)

I installed ffmpeg on a dedicated CenOs 6.3 server. The installation mostly follows the instrcutions given by the eFFMPEG group here, but there are few important twists if you want to get it done.

1. Login as root

2.Pre-set:
# remove older installations
yum erase ffmpeg x264 x264-devel
 
#verify you get all teh tools:
yum install gcc git make nasm pkgconfig wget
 
#create a working folder
mkdir ~/ffmpeg-source
 
3. Installations
 
#install yam 
cd ~/ffmpeg-source
wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
tar xzvf yasm-1.2.0.tar.gz
cd yasm-1.2.0
./configure
make
make install
 
#install x264
cd ~/ffmpeg-source
git clone git://git.videolan.org/x264
cd x264
./configure --enable-static
make
make install
 
#install mp3 encoder
cd ~/ffmpeg-source
wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
tar xzvf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure --disable-shared --enable-nasm
make
make install 

#install libogg
cd ~/ffmpeg-source
wget http://downloads.xiph.org/releases/ogg/libogg-1.3.0.tar.gz
tar xzvf libogg-1.3.0.tar.gz
cd libogg-1.3.0
./configure --disable-shared
make
make install
 
#install libvorbis
cd ~/ffmpeg-source
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.3.tar.gz
tar xzvf libvorbis-1.3.3.tar.gz
cd libvorbis-1.3.3
./configure --disable-shared
make
make install 

#install libvpx
cd ~/ffmpeg-source
git clone http://git.chromium.org/webm/libvpx.git
cd libvpx
./configure
make
make install
 
#install zlib
cd ~/ffmpeg-source
wget http://zlib.net/zlib-1.2.7.tar.gz
tar xzvf zlib-1.2.7.tar.gz
cd zlib-1.2.7
./configure
make
make install 

#FFMPEG did not want to work well in /tmp
mkdir ~/tmp
export TMPDIR=~/tmp

#you might also need to add to PATH /usr/lib
export PATH=$PATH:/usr/lib

#and probably add (I did it, but not sure it is a must)
export LD_LIBRARY_PATH=/usr/local/lib

#now install ffmeg from GIT repository
cd ~/ffmpeg-source
git clone git://source.ffmpeg.org/ffmpeg
cd ffmpeg
./configure --enable-gpl --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libx264
make
make install
 
#this should work now! type 'ffmpeg' to try
ffmpeg
ffmpeg version N-47639-g0110108 Copyright (c) 2000-2012 the FFmpeg developers
  built on Dec  8 2012 22:03:48 with gcc 4.4.6 (GCC) 20120305 (Red Hat 4.4.6-4)
  configuration: --enable-gpl --enable-libmp3lame --enable-libvorbis --enable-libvpx --enable-libx264
  libavutil      52. 12.100 / 52. 12.100
  libavcodec     54. 79.100 / 54. 79.100
  libavformat    54. 48.100 / 54. 48.100
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 26.100 /  3. 26.100
  libswscale      2.  1.103 /  2.  1.103
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg' 

Tuesday, November 06, 2012

Remove or Add MySQL user

Removing a user

-- first, let's see if the user is listed 
mysql> select * from mysql.user;

 
-- now let's kill the guy 
mysql> show grants for 'idiot'@'localhost';
mysql> revoke all privileges, grant option from 'idiot'@'localhost';
mysql> drop user 'idiot'@'localhost';
 
Adding a user

-- allow user to connect to the server
mysql> grant usage on *.* to amarokuser@localhost identified by 'amarokpasswd';

-- allow user to connect to the server 
mysql> grant all privileges on amarokdb.* to amarokuser@localhost ; 

-- another option (run mysql client as root, enter on command line) 
-- allows access from any IP for 'user'
GRANT ALL ON *.* to user@'%' IDENTIFIED BY 'password';

-- test if everything is OK now
mysql -u amarokuser -p'amarokpasswd' amarokdb