From 2c8ad5ee720fea5b1948a8ff0f27d966444ba9d7 Mon Sep 17 00:00:00 2001 From: monnerat Date: Fri, 12 Oct 2012 01:07:01 +0100 Subject: [PATCH] ASN1: _encode_der(): do not encode optional fields with value set to default. --- phpseclib/File/ASN1.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpseclib/File/ASN1.php b/phpseclib/File/ASN1.php index ad57b392..41d0a502 100644 --- a/phpseclib/File/ASN1.php +++ b/phpseclib/File/ASN1.php @@ -728,6 +728,11 @@ class File_ASN1 { return $source->element; } + // do not encode optional fields with value set to default + if (!empty($mapping['optional']) && isset($mapping['default']) && $source === $mapping['default']) { + return ''; + } + if (isset($idx)) { $this->location[] = $idx; }