|
@@ -152,6 +152,10 @@ void certstore_add ( struct x509_certificate *cert ) {
|
152
|
152
|
*/
|
153
|
153
|
void certstore_del ( struct x509_certificate *cert ) {
|
154
|
154
|
|
|
155
|
+ /* Ignore attempts to remove permanent certificates */
|
|
156
|
+ if ( cert->flags & X509_FL_PERMANENT )
|
|
157
|
+ return;
|
|
158
|
+
|
155
|
159
|
/* Remove certificate from store */
|
156
|
160
|
DBGC ( &certstore, "CERTSTORE removed certificate %s\n",
|
157
|
161
|
x509_name ( cert ) );
|
|
@@ -171,11 +175,22 @@ static unsigned int certstore_discard ( void ) {
|
171
|
175
|
* only reference is held by the store itself.
|
172
|
176
|
*/
|
173
|
177
|
list_for_each_entry_reverse ( cert, &certstore.links, store.list ) {
|
174
|
|
- if ( cert->refcnt.count == 0 ) {
|
175
|
|
- certstore_del ( cert );
|
176
|
|
- return 1;
|
177
|
|
- }
|
|
178
|
+
|
|
179
|
+ /* Skip certificates for which another reference is held */
|
|
180
|
+ if ( cert->refcnt.count > 0 )
|
|
181
|
+ continue;
|
|
182
|
+
|
|
183
|
+ /* Skip certificates that were added at build time or
|
|
184
|
+ * added explicitly at run time.
|
|
185
|
+ */
|
|
186
|
+ if ( cert->flags & ( X509_FL_PERMANENT | X509_FL_EXPLICIT ) )
|
|
187
|
+ continue;
|
|
188
|
+
|
|
189
|
+ /* Discard certificate */
|
|
190
|
+ certstore_del ( cert );
|
|
191
|
+ return 1;
|
178
|
192
|
}
|
|
193
|
+
|
179
|
194
|
return 0;
|
180
|
195
|
}
|
181
|
196
|
|