@@ -21,7 +21,6 @@ import (
2121 "crypto/tls"
2222 "errors"
2323 "fmt"
24- neturl "net/url"
2524 "os"
2625 "path"
2726
@@ -123,7 +122,7 @@ func configureAuthentication(ctx context.Context, c client.Client, obj *sourcev1
123122 }
124123 certSecret = secret
125124
126- tlsConfig , err := secrets .TLSConfigFromSecret (ctx , secret )
125+ tlsConfig , err := secrets .TLSConfigFromSecret (ctx , secret , obj . Spec . URL , obj . Spec . Insecure )
127126 if err != nil {
128127 return false , nil , nil , fmt .Errorf ("failed to construct Helm client's TLS config: %w" , err )
129128 }
@@ -139,7 +138,7 @@ func configureAuthentication(ctx context.Context, c client.Client, obj *sourcev1
139138 }
140139 authSecret = secret
141140
142- methods , err := secrets .AuthMethodsFromSecret (ctx , secret )
141+ methods , err := secrets .AuthMethodsFromSecret (ctx , secret , secrets . WithTLS ( obj . Spec . URL , obj . Spec . Insecure ) )
143142 if err != nil {
144143 return false , nil , nil , fmt .Errorf ("failed to detect authentication methods: %w" , err )
145144 }
@@ -156,20 +155,6 @@ func configureAuthentication(ctx context.Context, c client.Client, obj *sourcev1
156155 }
157156 }
158157
159- // Set ServerName for proper virtual hosting support.
160- // This is crucial for Helm repositories that use virtual hosting where multiple
161- // repositories are hosted on the same IP address. Without ServerName, the TLS
162- // handshake would fail with a certificate mismatch error.
163- // Note: runtime/secrets does not set ServerName, so this must be done at the
164- // controller level to ensure proper TLS SNI (Server Name Indication) support.
165- if opts .TlsConfig != nil {
166- u , err := neturl .Parse (url )
167- if err != nil {
168- return false , nil , nil , fmt .Errorf ("cannot parse repository URL: %w" , err )
169- }
170- opts .TlsConfig .ServerName = u .Hostname ()
171- }
172-
173158 return deprecatedTLS , certSecret , authSecret , nil
174159}
175160
0 commit comments