Populating Trusted CAs in X509Registry
As many might be (painfully) aware, VisualWorks’ SSL implementation does not come with its own collection of trusted certification authorities (CAs), similar to cURL or OpenSSL. Instead, developers wishing to call secure services must add whichever CAs they wish to trust to X509Registry explicitly by exporting them from a browser or using OpenSSL first and then importing into VisualWorks.
The following snippet uses a weekly extract of Mozilla’s CA bundle (link) to populate the registry instead, which should be sufficient for most folks simply wanting to make HTTPS requests without fiddling with registries or #proceed’ing SSLBadCertificate exceptions.
| pem bundle | pem := (HttpClient get: 'http://curl.haxx.se/ca/cacert.pem') contents. bundle := CertificateFileReader new readFrom: pem readStream. X509Registry trustedCertificates addAll: bundle.
Categories: Hints, Smalltalk, VisualWorks