|
@@ -93,6 +93,10 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
93
|
93
|
__einfo_error ( EINFO_EACCES_PATH_LEN )
|
94
|
94
|
#define EINFO_EACCES_PATH_LEN \
|
95
|
95
|
__einfo_uniqify ( EINFO_EACCES, 0x05, "Maximum path length exceeded" )
|
|
96
|
+#define EACCES_UNTRUSTED \
|
|
97
|
+ __einfo_error ( EINFO_EACCES_UNTRUSTED )
|
|
98
|
+#define EINFO_EACCES_UNTRUSTED \
|
|
99
|
+ __einfo_uniqify ( EINFO_EACCES, 0x06, "Untrusted root certificate" )
|
96
|
100
|
|
97
|
101
|
/** "commonName" object identifier */
|
98
|
102
|
static uint8_t oid_common_name[] = { ASN1_OID_COMMON_NAME };
|
|
@@ -1179,10 +1183,18 @@ int x509_validate_chain ( int ( * parse_next )
|
1179
|
1183
|
if ( ( rc = x509_validate_time ( current, time ) ) != 0 )
|
1180
|
1184
|
return rc;
|
1181
|
1185
|
|
1182
|
|
- /* Succeed if we have reached a root certificate */
|
|
1186
|
+ /* Succeed if we have reached a trusted root certificate */
|
1183
|
1187
|
if ( x509_validate_root ( current, root ) == 0 )
|
1184
|
1188
|
return 0;
|
1185
|
1189
|
|
|
1190
|
+ /* Fail if we have reached an untrusted root certificate */
|
|
1191
|
+ if ( asn1_compare ( ¤t->issuer.raw,
|
|
1192
|
+ ¤t->subject.raw ) == 0 ) {
|
|
1193
|
+ DBGC ( context, "X509 chain %p reached untrusted root "
|
|
1194
|
+ "certificate\n", context );
|
|
1195
|
+ return -EACCES_UNTRUSTED;
|
|
1196
|
+ }
|
|
1197
|
+
|
1186
|
1198
|
/* Get next certificate in chain */
|
1187
|
1199
|
if ( ( rc = parse_next ( next, current, context ) ) != 0 ) {
|
1188
|
1200
|
DBGC ( context, "X509 chain %p could not get next "
|