Branch: Tag:

2002-11-26

2002-11-26 22:20:34 by H. William Welliver III <bill@welliver.org>

more documentation for SSLPort

Rev: lib/modules/Protocols.pmod/HTTP.pmod/Server.pmod/SSLPort.pike:1.2

16:   //! The simplest SSL server possible. Binds a port and calls   //! a callback with <ref to=Request>Server.Request</ref> objects.    - //! method void create(function(Request:void) callback) - //! method void create(function(Request:void) callback,int portno,void|string interface, void|string key, void|string certificate) + //! Create a HTTPS (HTTP over SSL) server. + //! + //! @param _callback + //! the function run when a request is received. + //! takes one argument of type <ref to=Request>Server.Request</ref>. + //! @param _portno + //! the port number to bind to, defaults to 443 + //! @param _interface + //! the interface address to bind to + //! @param key + //! an optional SSL secret key, provided in binary format, such as that created by <ref + //! to=Standards.PKCS.RSA.private_key>Standards.PKCS.RSA.private_key()</ref> + //! @param certificate + //! an optional SSL certificate, provided in binary format   void create(function(Request:void) _callback,    void|int _portno,    void|string _interface, void|string key, void|string certificate)   {    portno=_portno; -  if (!portno) portno=80; // default HTTP port +  if (!portno) portno=443; // default HTTPS port       callback=_callback;    interface=_interface;
41:    portno,strerror(port->errno()));   }    - //! method void close() +    //! Closes the HTTP port. -  +    void close()   {    destruct(port);
113:    set_certificate(my_certificate);   }    - void set_key(string key) + void set_key(string skey)   {   #if 0 -  array key = SSL.asn1.ber_decode(key)->get_asn1()[1]; +  array key = SSL.asn1.ber_decode(skey)->get_asn1()[1];    object n = key[1][1];    object e = key[2][1];    object d = key[3][1];
128:    rsa->set_private_key(d);   #else /* !0 */    // FIXME: Is this correct? -  rsa = Standards.PKCS.RSA.parse_private_key(key); +  rsa = Standards.PKCS.RSA.parse_private_key(skey);   #endif /* 0 */       }