diff mbox series

[1/2] package/ca-certificates: don't hash certificates.crt

Message ID 20180506161944.7451-1-martin@barkynet.com
State Changes Requested
Headers show
Series [1/2] package/ca-certificates: don't hash certificates.crt | expand

Commit Message

Martin Bark May 6, 2018, 4:19 p.m. UTC
Copy certificates.crt to /etc/ssl/certs after we run c_rehash to
prevent it getting hashed by mistake.

Signed-off-by: Martin Bark <martin@barkynet.com>
---
 package/ca-certificates/ca-certificates.mk | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Peter Korsgaard May 29, 2018, 6:50 a.m. UTC | #1
>>>>> "Martin" == Martin Bark <martin@barkynet.com> writes:

 > Copy certificates.crt to /etc/ssl/certs after we run c_rehash to
 > prevent it getting hashed by mistake.

What is the effect of running c_rehash on it? Just an extra symlink or
any functional difference?

 > Signed-off-by: Martin Bark <martin@barkynet.com>
 > ---
 >  package/ca-certificates/ca-certificates.mk | 8 +++++++-
 >  1 file changed, 7 insertions(+), 1 deletion(-)

 > diff --git a/package/ca-certificates/ca-certificates.mk b/package/ca-certificates/ca-certificates.mk
 > index cb0e961465..b99e6f47ca 100644
 > --- a/package/ca-certificates/ca-certificates.mk
 > +++ b/package/ca-certificates/ca-certificates.mk
 > @@ -30,14 +30,20 @@ define CA_CERTIFICATES_INSTALL_TARGET_CMDS
 
 >  	# Create symlinks to certificates under /etc/ssl/certs
 >  	# and generate the bundle
 > +	rm -f $(@D)/ca-certificates.crt
 >  	cd $(TARGET_DIR) ;\
 >  	for i in `find usr/share/ca-certificates -name "*.crt"` ; do \
 >  		ln -sf ../../../$$i etc/ssl/certs/`basename $${i} .crt`.pem ;\
 > -		cat $$i >>etc/ssl/certs/ca-certificates.crt ;\
 > +		cat $$i >>$(@D)/ca-certificates.crt ;\
 >  	done

Alternatively we could redirect the entire for loop to the bundle, E.G.

done > $(@D)/ca-certificates.crt

While this seems like an improvement for when ca-certificates-reinstall
is run, I'm not sure what the relation is to $SUBJECT?


 >  	# Create symlinks to the certificates by their hash values
 >  	$(HOST_DIR)/bin/c_rehash $(TARGET_DIR)/etc/ssl/certs
 > +
 > +	# Install the certificates bundle we just created
 > +	$(INSTALL) -D -m 644 $(@D)/ca-certificates.crt \
 > +		$(TARGET_DIR)/etc/ssl/certs/ca-certificates.crt
 > +
 >  endef
 
 >  $(eval $(generic-package))
 > -- 
 > 2.17.0

 > _______________________________________________
 > buildroot mailing list
 > buildroot@busybox.net
 > http://lists.busybox.net/mailman/listinfo/buildroot
Martin Bark May 29, 2018, 9:48 a.m. UTC | #2
Peter,

On 29 May 2018 at 07:50, Peter Korsgaard <peter@korsgaard.com> wrote:

> >>>>> "Martin" == Martin Bark <martin@barkynet.com> writes:
>
>  > Copy certificates.crt to /etc/ssl/certs after we run c_rehash to
>  > prevent it getting hashed by mistake.
>
> What is the effect of running c_rehash on it? Just an extra symlink or
> any functional difference?
>

c_rehash hashes certificates.crt by mistake and that symlink clashes with
one of the CA certificates.  The end result is one of the hashes
incorrectly points to certificates.crt instead of the CA certificate.  I
noticed this during testing because i checked /etc/ssl/certs was the same
as under ubuntu.

Thanks Martin


>
>  > Signed-off-by: Martin Bark <martin@barkynet.com>
>  > ---
>  >  package/ca-certificates/ca-certificates.mk | 8 +++++++-
>  >  1 file changed, 7 insertions(+), 1 deletion(-)
>
>  > diff --git a/package/ca-certificates/ca-certificates.mk
> b/package/ca-certificates/ca-certificates.mk
>  > index cb0e961465..b99e6f47ca 100644
>  > --- a/package/ca-certificates/ca-certificates.mk
>  > +++ b/package/ca-certificates/ca-certificates.mk
>  > @@ -30,14 +30,20 @@ define CA_CERTIFICATES_INSTALL_TARGET_CMDS
>
>  >      # Create symlinks to certificates under /etc/ssl/certs
>  >      # and generate the bundle
>  > +    rm -f $(@D)/ca-certificates.crt
>  >      cd $(TARGET_DIR) ;\
>  >      for i in `find usr/share/ca-certificates -name "*.crt"` ; do \
>  >              ln -sf ../../../$$i etc/ssl/certs/`basename $${i}
> .crt`.pem ;\
>  > -            cat $$i >>etc/ssl/certs/ca-certificates.crt ;\
>  > +            cat $$i >>$(@D)/ca-certificates.crt ;\
>  >      done
>
> Alternatively we could redirect the entire for loop to the bundle, E.G.
>
> done > $(@D)/ca-certificates.crt
>
> While this seems like an improvement for when ca-certificates-reinstall
> is run, I'm not sure what the relation is to $SUBJECT?
>
>  >      # Create symlinks to the certificates by their hash values
>  >      $(HOST_DIR)/bin/c_rehash $(TARGET_DIR)/etc/ssl/certs
>  > +
>  > +    # Install the certificates bundle we just created
>  > +    $(INSTALL) -D -m 644 $(@D)/ca-certificates.crt \
>  > +            $(TARGET_DIR)/etc/ssl/certs/ca-certificates.crt
>  > +
>  >  endef
>
>  >  $(eval $(generic-package))
>  > --
>  > 2.17.0
>
>  > _______________________________________________
>  > buildroot mailing list
>  > buildroot@busybox.net
>  > http://lists.busybox.net/mailman/listinfo/buildroot
>
> --
> Bye, Peter Korsgaard
>
<div dir="ltr">Peter,<div class="gmail_extra"><br><div class="gmail_quote">On 29 May 2018 at 07:50, Peter Korsgaard <span dir="ltr">&lt;<a href="mailto:peter@korsgaard.com" target="_blank">peter@korsgaard.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>&gt;&gt;&gt;&gt;&gt; &quot;Martin&quot; == Martin Bark &lt;<a href="mailto:martin@barkynet.com" target="_blank">martin@barkynet.com</a>&gt; writes:<br>
<br>
 &gt; Copy certificates.crt to /etc/ssl/certs after we run c_rehash to<br>
 &gt; prevent it getting hashed by mistake.<br>
<br>
</span>What is the effect of running c_rehash on it? Just an extra symlink or<br>
any functional difference?<br></blockquote><div><br></div><div>c_rehash hashes certificates.crt by mistake and that symlink clashes with one of the CA certificates.  The end result is one of the hashes incorrectly points to certificates.crt instead of the CA certificate.  I noticed this during testing because i checked /etc/ssl/certs was the same as under ubuntu.</div><div><br></div><div>Thanks Martin</div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span><br>
 &gt; Signed-off-by: Martin Bark &lt;<a href="mailto:martin@barkynet.com" target="_blank">martin@barkynet.com</a>&gt;<br>
 &gt; ---<br>
 &gt;  package/ca-certificates/<a href="http://ca-certificates.mk" rel="noreferrer" target="_blank">ca-cer<wbr>tificates.mk</a> | 8 +++++++-<br>
 &gt;  1 file changed, 7 insertions(+), 1 deletion(-)<br>
<br>
 &gt; diff --git a/package/ca-certificates/<a href="http://ca-certificates.mk" rel="noreferrer" target="_blank">ca-c<wbr>ertificates.mk</a> b/package/ca-certificates/<a href="http://ca-certificates.mk" rel="noreferrer" target="_blank">ca-c<wbr>ertificates.mk</a><br>
 &gt; index cb0e961465..b99e6f47ca 100644<br>
 &gt; --- a/package/ca-certificates/<a href="http://ca-certificates.mk" rel="noreferrer" target="_blank">ca-c<wbr>ertificates.mk</a><br>
 &gt; +++ b/package/ca-certificates/<a href="http://ca-certificates.mk" rel="noreferrer" target="_blank">ca-c<wbr>ertificates.mk</a><br>
 &gt; @@ -30,14 +30,20 @@ define CA_CERTIFICATES_INSTALL_TARGET<wbr>_CMDS<br>
<br>
 &gt;      # Create symlinks to certificates under /etc/ssl/certs<br>
 &gt;      # and generate the bundle<br>
 &gt; +    rm -f $(@D)/ca-certificates.crt<br>
 &gt;      cd $(TARGET_DIR) ;\<br>
 &gt;      for i in `find usr/share/ca-certificates -name &quot;*.crt&quot;` ; do \<br>
 &gt;              ln -sf ../../../$$i etc/ssl/certs/`basename $${i} .crt`.pem ;\<br>
 &gt; -            cat $$i &gt;&gt;etc/ssl/certs/ca-certificate<wbr>s.crt ;\<br>
 &gt; +            cat $$i &gt;&gt;$(@D)/ca-certificates.crt ;\<br>
 &gt;      done<br>
<br>
</span>Alternatively we could redirect the entire for loop to the bundle, E.G.<br>
<br>
done &gt; $(@D)/ca-certificates.crt<br>
<br>
While this seems like an improvement for when ca-certificates-reinstall<br>
is run, I&#39;m not sure what the relation is to $SUBJECT?<br><span><br>
 &gt;      # Create symlinks to the certificates by their hash values<br>
 &gt;      $(HOST_DIR)/bin/c_rehash $(TARGET_DIR)/etc/ssl/certs<br>
 &gt; +<br>
 &gt; +    # Install the certificates bundle we just created<br>
 &gt; +    $(INSTALL) -D -m 644 $(@D)/ca-certificates.crt \<br>
 &gt; +            $(TARGET_DIR)/etc/ssl/certs/ca<wbr>-certificates.crt<br>
 &gt; +<br>
 &gt;  endef<br>
<br>
 &gt;  $(eval $(generic-package))<br>
 &gt; -- <br>
 &gt; 2.17.0<br>
<br>
</span> &gt; ______________________________<wbr>_________________<br>
 &gt; buildroot mailing list<br>
 &gt; <a href="mailto:buildroot@busybox.net" target="_blank">buildroot@busybox.net</a><br>
 &gt; <a href="http://lists.busybox.net/mailman/listinfo/buildroot" rel="noreferrer" target="_blank">http://lists.busybox.net/mailm<wbr>an/listinfo/buildroot</a><br>
<span class="m_-8341048113607729486HOEnZb"><font color="#888888"><br>
-- <br>
Bye, Peter Korsgaard<br>
</font></span></blockquote></div><br></div></div>
Peter Korsgaard May 29, 2018, 10:08 a.m. UTC | #3
>>>>> "Martin" == Martin Bark <martin@barkynet.com> writes:

 > Peter,
 > On 29 May 2018 at 07:50, Peter Korsgaard <peter@korsgaard.com> wrote:

 >> >>>>> "Martin" == Martin Bark <martin@barkynet.com> writes:
 >> 
 >> > Copy certificates.crt to /etc/ssl/certs after we run c_rehash to
 >> > prevent it getting hashed by mistake.
 >> 
 >> What is the effect of running c_rehash on it? Just an extra symlink or
 >> any functional difference?
 >> 

 > c_rehash hashes certificates.crt by mistake and that symlink clashes with
 > one of the CA certificates.  The end result is one of the hashes
 > incorrectly points to certificates.crt instead of the CA certificate.  I
 > noticed this during testing because i checked /etc/ssl/certs was the same
 > as under ubuntu.

Ok, can you rework the commit message with these details (and perhaps
the for loop change) and resubmit? Thanks!
Martin Bark May 29, 2018, 10:40 a.m. UTC | #4
Peter,

On 29 May 2018 at 11:08, Peter Korsgaard <peter@korsgaard.com> wrote:

> >>>>> "Martin" == Martin Bark <martin@barkynet.com> writes:
>
>  > Peter,
>  > On 29 May 2018 at 07:50, Peter Korsgaard <peter@korsgaard.com> wrote:
>
>  >> >>>>> "Martin" == Martin Bark <martin@barkynet.com> writes:
>  >>
>  >> > Copy certificates.crt to /etc/ssl/certs after we run c_rehash to
>  >> > prevent it getting hashed by mistake.
>  >>
>  >> What is the effect of running c_rehash on it? Just an extra symlink or
>  >> any functional difference?
>  >>
>
>  > c_rehash hashes certificates.crt by mistake and that symlink clashes
> with
>  > one of the CA certificates.  The end result is one of the hashes
>  > incorrectly points to certificates.crt instead of the CA certificate.  I
>  > noticed this during testing because i checked /etc/ssl/certs was the
> same
>  > as under ubuntu.
>
> Ok, can you rework the commit message with these details (and perhaps
> the for loop change) and resubmit? Thanks!
>

Will do

Thanks

Martin


>
> --
> Bye, Peter Korsgaard
>
<div dir="ltr">Peter,<div class="gmail_extra"><br><div class="gmail_quote">On 29 May 2018 at 11:08, Peter Korsgaard <span dir="ltr">&lt;<a href="mailto:peter@korsgaard.com" target="_blank">peter@korsgaard.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">&gt;&gt;&gt;&gt;&gt; &quot;Martin&quot; == Martin Bark &lt;<a href="mailto:martin@barkynet.com">martin@barkynet.com</a>&gt; writes:<br>
<br>
 &gt; Peter,<br>
 &gt; On 29 May 2018 at 07:50, Peter Korsgaard &lt;<a href="mailto:peter@korsgaard.com">peter@korsgaard.com</a>&gt; wrote:<br>
<br>
 &gt;&gt; &gt;&gt;&gt;&gt;&gt; &quot;Martin&quot; == Martin Bark &lt;<a href="mailto:martin@barkynet.com">martin@barkynet.com</a>&gt; writes:<br>
 &gt;&gt; <br>
 &gt;&gt; &gt; Copy certificates.crt to /etc/ssl/certs after we run c_rehash to<br>
 &gt;&gt; &gt; prevent it getting hashed by mistake.<br>
 &gt;&gt; <br>
 &gt;&gt; What is the effect of running c_rehash on it? Just an extra symlink or<br>
 &gt;&gt; any functional difference?<br>
 &gt;&gt; <br>
<br>
 &gt; c_rehash hashes certificates.crt by mistake and that symlink clashes with<br>
 &gt; one of the CA certificates.  The end result is one of the hashes<br>
 &gt; incorrectly points to certificates.crt instead of the CA certificate.  I<br>
 &gt; noticed this during testing because i checked /etc/ssl/certs was the same<br>
 &gt; as under ubuntu.<br>
<br>
</span>Ok, can you rework the commit message with these details (and perhaps<br>
the for loop change) and resubmit? Thanks!<br></blockquote><div><br></div><div>Will do</div><div><br></div><div>Thanks</div><div><br></div><div>Martin</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
-- <br>
Bye, Peter Korsgaard<br>
</font></span></blockquote></div><br></div></div>
diff mbox series

Patch

diff --git a/package/ca-certificates/ca-certificates.mk b/package/ca-certificates/ca-certificates.mk
index cb0e961465..b99e6f47ca 100644
--- a/package/ca-certificates/ca-certificates.mk
+++ b/package/ca-certificates/ca-certificates.mk
@@ -30,14 +30,20 @@  define CA_CERTIFICATES_INSTALL_TARGET_CMDS
 
 	# Create symlinks to certificates under /etc/ssl/certs
 	# and generate the bundle
+	rm -f $(@D)/ca-certificates.crt
 	cd $(TARGET_DIR) ;\
 	for i in `find usr/share/ca-certificates -name "*.crt"` ; do \
 		ln -sf ../../../$$i etc/ssl/certs/`basename $${i} .crt`.pem ;\
-		cat $$i >>etc/ssl/certs/ca-certificates.crt ;\
+		cat $$i >>$(@D)/ca-certificates.crt ;\
 	done
 
 	# Create symlinks to the certificates by their hash values
 	$(HOST_DIR)/bin/c_rehash $(TARGET_DIR)/etc/ssl/certs
+
+	# Install the certificates bundle we just created
+	$(INSTALL) -D -m 644 $(@D)/ca-certificates.crt \
+		$(TARGET_DIR)/etc/ssl/certs/ca-certificates.crt
+
 endef
 
 $(eval $(generic-package))