Skip to content

fix: pass insecure registry options to image cache#1616

Merged
jabrown85 merged 1 commit intobuildpacks:mainfrom
zzzhangqi:fix-insecure-registry
Feb 19, 2026
Merged

fix: pass insecure registry options to image cache#1616
jabrown85 merged 1 commit intobuildpacks:mainfrom
zzzhangqi:fix-insecure-registry

Conversation

@zzzhangqi
Copy link
Contributor

Summary

NewImageCacheFromName did not pass insecure registry options to remote.NewImage(), causing TLS verification failures when using -insecure-registry with cache images stored on
registries that use self-signed certificates or plain HTTP.

Other code paths (pullSparse, initRemoteAppImage, RegistryHandler) already correctly call image.GetInsecureOptions, but the cache image path was missed.

This PR adds a variadic insecureRegistries parameter to NewImageCacheFromName and threads it through initCache, DefaultCacheHandler, and all callers (creator, restorer,
exporter, analyzer).

Release notes

When using -insecure-registry, cache images now correctly skip TLS verification, matching the existing behavior for app images.


Related

Resolves #___


Context

The bug can be reproduced by running the lifecycle with -insecure-registry=registry.example.com against a registry using self-signed certificates. App image operations (analyze,
export) succeed, but cache image restore/export fails with:

ERROR: failed to create image cache: accessing cache image "registry.example.com/cache:latest": tls: failed to verify certificate: x509: certificate signed by unknown authority

The fix uses a variadic parameter (insecureRegistries ...string) to maintain backward compatibility — existing callers without insecure registries continue to work unchanged.

Files changed:

  • cache/image_cache.go — add insecureRegistries param, apply GetInsecureOptions to both remote.NewImage calls
  • cmd/lifecycle/main.go — add insecureRegistries to DefaultCacheHandler and initCache
  • cmd/lifecycle/creator.go — pass InsecureRegistries to initCache and NewCacheHandler
  • cmd/lifecycle/restorer.go — pass InsecureRegistries to initCache
  • cmd/lifecycle/exporter.go — pass InsecureRegistries to initCache
  • cmd/lifecycle/analyzer.go — pass InsecureRegistries to NewCacheHandler

NewImageCacheFromName did not pass insecure registry options to
remote.NewImage, causing TLS verification failures when using
-insecure-registry with cache images stored on registries that use
self-signed certificates or plain HTTP.

Other code paths (pullSparse, initRemoteAppImage, RegistryHandler)
already correctly call image.GetInsecureOptions, but the cache image
path was missed.

Add a variadic insecureRegistries parameter to NewImageCacheFromName
and thread it through initCache, DefaultCacheHandler, and all callers
(creator, restorer, exporter, analyzer).

Signed-off-by: Qi Zhang <smallqi1@163.com>
@zzzhangqi zzzhangqi requested a review from a team as a code owner February 19, 2026 14:33
@zzzhangqi
Copy link
Contributor Author

zzzhangqi commented Feb 19, 2026

@jabrown85 please review

Copy link
Contributor

@jabrown85 jabrown85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me

@jabrown85 jabrown85 merged commit 062ab82 into buildpacks:main Feb 19, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants