os/security/cryptomgmtlibs/securitytestfw/test/autotesting/checklocationofcertificates.pl
Update contrib.
2 # Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
4 # This component and the accompanying materials are made available
5 # under the terms of the License "Eclipse Public License v1.0"
6 # which accompanies this distribution, and is available
7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 # Initial Contributors:
10 # Nokia Corporation - initial contribution.
15 # This script was written as part the solution for DEF116697: Remove Security Test Certificates from CBR
16 # The purpose of the defect was to stop the export of all test certificates that may not be Symbian owned.
17 # To accomplish this the certificates were all moved to a new location which does not get put in the CBR.
18 # This script is run in the ONB so that no new certificates are added to any directory that appears in the CBR.
19 # (Note that the certificates in rootcerts are Symbian owned and so can be exported.)
20 # This script takes 2 arguments
21 # - directory to search for certificates (defaults to \common\generic\security)
22 # - output file for result of test (defaults to $ENV{EPOCROOT}epoc32\\winscw\\c\\CheckLocationOfCertificatesLog.txt)
23 # The script searches through the specified directory for any certificate files (files ending in .cer, .der and .crt).
24 # It will print out the names of any files found.
30 # array holding the list of full path names to all the certificates found.
36 # Check for certificates which are not in valid locations
37 if (($File::Find::dir !~ m/\/testframework\/testcertificates/) && ($File::Find::dir !~ m/\/os\/security\/cryptoservices\/rootcertificates/) && ($File::Find::dir !~ m/\/os\/security\/cryptomgmtlibs\/securitytestfw\/testcertificates/))
39 if ($File::Find::name =~ m/\.cer$/i)
41 push @Certificates, $File::Find::name;
43 if ($File::Find::name =~ m/\.crt$/i)
45 push @Certificates, $File::Find::name;
47 if ($File::Find::name =~ m/\.der$/i)
49 push @Certificates, $File::Find::name;
51 if ($File::Find::name =~ m/\.pem$/i)
53 push @Certificates, $File::Find::name;
61 # Determine directory to search
65 $dirToSearch = $ARGV[0];
69 $dirToSearch = "$ENV{'SECURITYSOURCEDIR'}";
72 # Determine where to put the logs. This file will be parsed by the overnight build system.
76 $outputFile = $ARGV[1];
80 die "EPOCROOT not defined, must specify directory" if !defined ($ENV{EPOCROOT});
81 my $emulatorLogDirectory = "$ENV{EPOCROOT}logs\\winscw\\c";
83 if ( ! -d $emulatorLogDirectory )
85 system("md $ENV{EPOCROOT}logs\\winscw\\c");
87 $outputFile = "$ENV{EPOCROOT}epoc32\\winscw\\c\\checklocationofcertificateslog.txt";
91 die "\nUnable to open log $outputFile\n" if( not open( SCANLOG, ">$outputFile" ) );
94 print SCANLOG "\nScanning $dirToSearch for incorrectly located certificate files.\n\n";
97 # Search for certificate files
98 find { wanted => \&FindCerts, no_chdir => 1 }, $dirToSearch;
100 my $count = scalar(@Certificates);
104 print (SCANLOG "No certificates found in $dirToSearch. Test PASSED.\n\n");
105 print (SCANLOG "\nTests completed OK");
106 print (SCANLOG "\nRun: 1");
107 print (SCANLOG "\nPassed: 1");
108 print (SCANLOG "\n0 tests failed out of 1");
112 foreach $certificatefile (@Certificates)
114 $certificatefile =~ s/\//\\/g;
115 print (SCANLOG "Certificate: $certificatefile is in an invalid location. Should be moved to ......\\security\\testframework\\testcertificates\\...\n");
116 print (SCANLOG "Test for $certificatefile FAILED.\n\n");
118 print (SCANLOG "\nTests completed OK");
119 print (SCANLOG "\nRun: 1");
120 print (SCANLOG "\nPassed: 0");
121 print (SCANLOG "\n1 tests failed out of 1");