Author: jow
Date: 2014-11-03 19:12:42 +0100 (Mon, 03 Nov 2014)
New Revision: 43168

Modified:
   trunk/package/utils/px5g/Makefile
   trunk/package/utils/px5g/px5g.c
Log:
px5g: generate unique serial numbers

Generate a random serial from /dev/urandom when creating selfsigned certs.
Fixes "sec_error_reused_issuer_and_serial" with Firefox.

Signed-off-by: Jo-Philipp Wich <[email protected]>

Modified: trunk/package/utils/px5g/Makefile
===================================================================
--- trunk/package/utils/px5g/Makefile   2014-11-03 09:56:44 UTC (rev 43167)
+++ trunk/package/utils/px5g/Makefile   2014-11-03 18:12:42 UTC (rev 43168)
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2010 Jo-Philipp Wich <[email protected]>
+# Copyright (C) 2010-2014 Jo-Philipp Wich <[email protected]>
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -8,7 +8,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=px5g
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)
 PKG_USE_MIPS16:=0

Modified: trunk/package/utils/px5g/px5g.c
===================================================================
--- trunk/package/utils/px5g/px5g.c     2014-11-03 09:56:44 UTC (rev 43167)
+++ trunk/package/utils/px5g/px5g.c     2014-11-03 18:12:42 UTC (rev 43168)
@@ -143,7 +143,7 @@
        char *keypath = NULL, *certpath = NULL;
        bool pem = true;
        time_t from = time(NULL), to;
-       char fstr[20], tstr[20];
+       char fstr[20], tstr[20], sstr[17];
        int len;
 
        while (*arg && **arg == '-') {
@@ -222,8 +222,12 @@
        x509write_crt_set_subject_key_identifier(&cert);
        x509write_crt_set_authority_key_identifier(&cert);
 
+       _urandom(NULL, buf, 8);
+       for (len = 0; len < 8; len++)
+               sprintf(sstr + len*2, "%02x", (unsigned char) buf[len]);
+
        mpi_init(&serial);
-       mpi_read_string(&serial, 10, "1");
+       mpi_read_string(&serial, 16, sstr);
        x509write_crt_set_serial(&cert, &serial);
 
        if (pem) {
_______________________________________________
openwrt-commits mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-commits

Reply via email to