For ssl handshake:
Why do you want to code yourself? All web servers have ssl module, you just need to configure them. If you want to write ssl enabled app, you might need some coding. Even that can be done with ssl wrapper like stunnel (http://www.stunnel.org).
If you really want to code, you might want to refer to the following:
- OpenSSL (http://www.openssl.org)
- mod_ssl (http://www.modssl.org)
- apache-ssl (http://www.apache-ssl.org)
- RSA Security (http://www.rsasecurity.com/standards/ssl/developers.html)