Download needed packages for building OpenSSL:
apt-get build-dep libssl0.9.8
apt-get source libssl0.9.8
Then you have to alter the debian/rules file so as to disable the zlib during compilation.
CONFARGS = --prefix=/usr --openssldir=/usr/lib/ssl no-idea no-mdc2 no-rc5 no-zlib
Next you can start the build process:
dpkg-buildpackage -rfakeroot -b
dpkg -i libssl0.9.8_0.9.8g-8_amd64.deb openssl_0.9.8g-8_amd64.deb
The custom version is installed. You now have to prevent future updates from overwriting your custom versions:
root@sso-fe01:~# dpkg --set-selections
Of course, this means that when new openssl versions are released they won't be automatically installed. You have to repeat this process each time, specially since they tend to be security updates.