diff --git a/cloudfront.module b/cloudfront.module
index a85c562..8c8f2b8 100644
--- a/cloudfront.module
+++ b/cloudfront.module
@@ -27,6 +27,7 @@ function cloudfront_menu() {
  *   url on success, false on failure
  */
 function cloudfront_create_url($imagecache_namespace, $path) {
+  global $is_https;
   $preset_info = imagecache_preset_by_name($imagecache_namespace);
   if (!isset($preset_info['presetid'])) {
     return FALSE;
@@ -53,6 +54,11 @@ SQL;
 
   $results = db_query($sql, $preset_info['presetid'], $path);
   if ($item = db_fetch_object($results)) {
+    // check for SSL
+    if ($is_https || $_SERVER['HTTPS'] == 'on' || $_SERVER['SERVER_PORT'] == 443) {
+      $item->distribution_url = str_replace('http://', 'https://', $item->distribution_url);
+    }
+
     // Get the URL that would be used for imagecache
     $imagecache_url = imagecache_create_url($imagecache_namespace, $path);
     // Now strip everything leading up to and including the presetname and
