author | andy simpson <andrews@symbian.org> |
Fri, 20 Nov 2009 14:25:08 +0000 | |
changeset 18 | 538fe06033d7 |
parent 4 | 8e4b1aa36db9 |
permissions | -rw-r--r-- |
4
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
1 |
# |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
2 |
# Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
3 |
# All rights reserved. |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
4 |
# This component and the accompanying materials are made available |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
5 |
# under the terms of the License "Eclipse Public License v1.0" |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
6 |
# which accompanies this distribution, and is available |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
8 |
# |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
9 |
# Initial Contributors: |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
10 |
# Nokia Corporation - initial contribution. |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
11 |
# |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
12 |
# Contributors: |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
13 |
# |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
14 |
# Description: |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
15 |
# Script to convert the Mozilla certificate store into the store format Symbian OS understands. |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
16 |
# |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
17 |
# Mozilla certificate store and its associated license is available at |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
18 |
# http://mxr.mozilla.org/mozilla/source/security/nss/lib/ckfw/builtins/certdata.txt?raw=1 |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
19 |
# |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
20 |
# |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
21 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
22 |
import string, getopt, sys, subprocess, glob, os |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
23 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
24 |
# |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
25 |
# Default input files |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
26 |
# |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
27 |
inFileMozillaCerts = "certdata.txt" |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
28 |
inFileTrustMapping = "trustmapping.txt" |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
29 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
30 |
# |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
31 |
# Output path (don't change this!) and other temp files |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
32 |
# |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
33 |
outPath = ".\\" |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
34 |
outFileCaCerts = "cacerts_text.txt" |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
35 |
outFileCertClients = "certclients_text.txt" |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
36 |
outCertAppOutput = "output.txt" |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
37 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
38 |
# |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
39 |
# Constants |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
40 |
# |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
41 |
ERROR_NONE = 0 |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
42 |
ERROR_EOF = -1 |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
43 |
ERROR_GENERAL = -2 |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
44 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
45 |
# |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
46 |
# Class CertRecord |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
47 |
# |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
48 |
class CertRecord: |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
49 |
def __init__(self, file): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
50 |
self.file = file |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
51 |
# Read over the first CKA_CLASS record |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
52 |
value = "" |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
53 |
self.ReadTokenValue("CKA_CLASS") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
54 |
# Can we assert if value != "CKO_NETSCAPE_BUILTIN_ROOT_LIST" |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
55 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
56 |
# Read and parse next record, return 0 if no more records exist |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
57 |
def Next(self): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
58 |
# Read next certificate token |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
59 |
err, value = self.ReadTokenValue("CKA_CLASS") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
60 |
if (err == ERROR_EOF): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
61 |
return err |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
62 |
if (err != ERROR_NONE or value != "CKO_CERTIFICATE"): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
63 |
return err |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
64 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
65 |
# Read the cert label |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
66 |
err, self.certLabel = self.ReadTokenValue("CKA_LABEL") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
67 |
if (err != ERROR_NONE): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
68 |
return err |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
69 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
70 |
# Read the cert type |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
71 |
err, self.certType = self.ReadTokenValue("CKA_CERTIFICATE_TYPE") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
72 |
if (err != ERROR_NONE): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
73 |
return err |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
74 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
75 |
# Read the cert serial number |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
76 |
err, self.certSerialNum = self.ReadTokenValue("CKA_SERIAL_NUMBER") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
77 |
if (err != ERROR_NONE): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
78 |
return err |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
79 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
80 |
# Read the actual cert data (DER encoded) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
81 |
err, self.certData = self.ReadTokenValue("CKA_VALUE") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
82 |
if (err != ERROR_NONE): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
83 |
return err |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
84 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
85 |
# Read the trust details |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
86 |
err, value = self.ReadTokenValue("CKA_CLASS") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
87 |
if (err != ERROR_NONE or value != "CKO_NETSCAPE_TRUST"): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
88 |
return err |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
89 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
90 |
# Read the trust label and match it with cert label |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
91 |
err, self.trustLabel = self.ReadTokenValue("CKA_LABEL") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
92 |
if (err != ERROR_NONE or self.trustLabel != self.certLabel): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
93 |
print "Certificate and Trust label mismatch or not found for cert " + self.certLabel |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
94 |
return err |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
95 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
96 |
# Read the SHA1 hash (aka thumbprint) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
97 |
err, self.trustSha1Hash = self.ReadTokenValue("CKA_CERT_SHA1_HASH") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
98 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
99 |
# Read the trust serial number and match it with cert serial number |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
100 |
err, self.trustSerialNum = self.ReadTokenValue("CKA_SERIAL_NUMBER") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
101 |
if (err != ERROR_NONE or self.trustSerialNum != self.certSerialNum): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
102 |
print "Warning: Certificate and Trust serial number mismatch or not found for cert " + self.certLabel |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
103 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
104 |
# Read the trust list. This has a variable token so can't use ReadTokenValue method |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
105 |
err, self.trustTrustList = self.ReadTrustValues() |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
106 |
if (err != ERROR_NONE): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
107 |
return err |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
108 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
109 |
return ERROR_NONE |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
110 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
111 |
def ReadTrustValues(self): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
112 |
# Keep reading lines till token "CKA_TRUST_STEP_UP_APPROVED" found |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
113 |
trustList = [] |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
114 |
for line in self.file: |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
115 |
line = line.rstrip('\n') |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
116 |
fields = line.split(" ") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
117 |
if (len(fields) == 0): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
118 |
continue |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
119 |
if (fields[0] == "CKA_TRUST_STEP_UP_APPROVED"): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
120 |
# Done reading trust settings |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
121 |
return ERROR_NONE, trustList |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
122 |
break |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
123 |
if (fields[1] == "CK_TRUST"): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
124 |
if ((fields[2] == "CKT_NETSCAPE_TRUSTED_DELEGATOR")): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
125 |
trustList.append(fields[0].strip()) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
126 |
else: |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
127 |
# Something is wrong |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
128 |
print "Error reading trust settings. " + line |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
129 |
return ERROR_GENERAL, [] |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
130 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
131 |
# End of file? |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
132 |
if (line == ""): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
133 |
return ERROR_EOF, "" |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
134 |
print "Error in ReadTrustValues(). Token ('CKA_TRUST_STEP_UP_APPROVED') not found!" |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
135 |
return ERROR_GENERAL, "" |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
136 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
137 |
def ReadTokenValue(self, token): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
138 |
# Keep reading lines till token found |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
139 |
for line in self.file: |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
140 |
line = line.rstrip('\n') |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
141 |
fields = line.split(" ") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
142 |
if (len(fields) == 0): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
143 |
continue |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
144 |
if (fields[0] == token): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
145 |
if (fields[1] != "MULTILINE_OCTAL"): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
146 |
value = " ".join(fields[2:]) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
147 |
return ERROR_NONE, value |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
148 |
else: |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
149 |
# Read multiline octal value till END |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
150 |
value="" |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
151 |
for nextline in self.file: |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
152 |
nextline = nextline.rstrip('\n') |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
153 |
if (nextline == "END"): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
154 |
break |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
155 |
if (nextline != ""): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
156 |
# Convert string of octal to binary data |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
157 |
# There must be an easier way than this! |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
158 |
octalWordList = nextline.split("\\") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
159 |
for octalWord in octalWordList: |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
160 |
if (octalWord != ""): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
161 |
value = value + chr(int(octalWord, 8)) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
162 |
else: |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
163 |
print "ReadTokenValue(" + token + ") awaiting END. Unexpected end of file!" |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
164 |
return ERROR_EOF, "" |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
165 |
return ERROR_NONE, value |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
166 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
167 |
#print "ReadTokenValue(" + token + "). Token not found!" |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
168 |
return ERROR_EOF, "" |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
169 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
170 |
# |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
171 |
# Global function ReadTrustMapping() |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
172 |
# |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
173 |
def ReadTrustMapping(file): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
174 |
trustMapping = [] |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
175 |
for line in file: |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
176 |
line = line.rstrip('\n') |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
177 |
if (line == "" or line[0] == "#"): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
178 |
continue |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
179 |
fields = line.split(",") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
180 |
if (len(fields) == 0): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
181 |
continue |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
182 |
if ((len(fields) % 2) != 1): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
183 |
print "Error in file '%s' in line '%s'\n" % inFileTrustMapping % line |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
184 |
return GENERAL_ERROR, [[]] |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
185 |
mozTrust = fields[0].strip() |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
186 |
for index in range(1, len(fields), 2): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
187 |
appUID = fields[index].strip() |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
188 |
appName = fields[index + 1].strip() |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
189 |
trustMapping.append([mozTrust, appUID, appName]) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
190 |
return ERROR_NONE, trustMapping |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
191 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
192 |
# |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
193 |
# Global function ReadCommandlineArgs() |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
194 |
# |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
195 |
def ReadCommandlineArgs(argv): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
196 |
try: |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
197 |
flags, args = getopt.getopt(argv[1:], "hm:t:", ["help", "mozilla=", "trust="]) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
198 |
except getopt.GetoptError, err: |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
199 |
# Print usage |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
200 |
print str(err) + "\n" |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
201 |
PrintUsage() |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
202 |
sys.exit(-1) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
203 |
for flag, arg in flags: |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
204 |
if flag in ("-h", "--help"): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
205 |
PrintUsage() |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
206 |
sys.exit() |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
207 |
elif flag in ("-m", "--mozilla"): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
208 |
globals()["inFileMozillaCerts"] = arg |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
209 |
elif flag in ("-t", "--trust"): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
210 |
globals()["inFileTrustMapping"] = arg |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
211 |
print "certconvert - This script converts the Mozilla certificate store into Symbian OS certificate store." |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
212 |
print "\nInput Mozilla store file: %s" % globals()["inFileMozillaCerts"] |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
213 |
print "Input trust mapping: %s" % globals()["inFileTrustMapping"] |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
214 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
215 |
# |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
216 |
# |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
217 |
# |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
218 |
def PrintUsage(): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
219 |
print "certconvert - This script converts the Mozilla certificate store into Symbian OS certificate store." |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
220 |
print "It uses certapp for the conversion so certapp must be in the path." |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
221 |
print "Usage: certconvert [-h] | [-m <file> -t <file>] [-o <outpath>]" |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
222 |
print "where:" |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
223 |
print "-h | --help\tshows this help" |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
224 |
print "-m | --mozilla\tis used to specify the Mozilla certificate store input file." |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
225 |
print "\t\tIf not specified default is taken as 'certdata.txt'." |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
226 |
print "-t | --trust\tis used to specify the input trust mapping input file." |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
227 |
print "\t\tThis file maps the trust settings from the Mozilla store to " |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
228 |
print "\t\tSymbian's applications and uids." |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
229 |
print "\t\tIf not specified default is taken as 'trustmapping.txt'." |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
230 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
231 |
# |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
232 |
# Main starts here |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
233 |
# |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
234 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
235 |
# Read and process command line arguments |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
236 |
ReadCommandlineArgs(sys.argv) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
237 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
238 |
# First read the trust mappings file |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
239 |
print "Reading trust mapping file...", |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
240 |
file = open(inFileTrustMapping, "r") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
241 |
err, trustMapping = ReadTrustMapping(file) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
242 |
if (err != ERROR_NONE): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
243 |
print "\nError reading trust mapping file!\n" |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
244 |
sys.exit(-1) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
245 |
file.close() |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
246 |
print "done." |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
247 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
248 |
print "Reading Mozilla certificate store and processing certificates", |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
249 |
inFileMoz=open(inFileMozillaCerts, "r") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
250 |
record = CertRecord(inFileMoz) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
251 |
inRecNum = outRecNum = 0 |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
252 |
while (record.Next() == ERROR_NONE): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
253 |
inRecNum = inRecNum + 1 |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
254 |
#print "Read record %d: %s" % (inRecNum, record.certLabel) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
255 |
# Do filtering of records (if any) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
256 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
257 |
outRecNum = outRecNum + 1 |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
258 |
# Create the human readable filecertstore entry |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
259 |
if (outRecNum == 1): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
260 |
if (os.path.exists(outPath) == False): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
261 |
os.makedirs(outPath) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
262 |
if (os.path.exists(outPath + "\\certs") == False): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
263 |
os.makedirs(outPath + "\\certs") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
264 |
outFileSym = open(outPath + outFileCaCerts, "w") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
265 |
outFileSym.write("StartCertStoreEntries\n") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
266 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
267 |
outFileSym.write("\t# Entry %d\n" % outRecNum) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
268 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
269 |
# Write out the SHA1 hash of the certificate (to make it easier to compare certs) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
270 |
# Convert to hex |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
271 |
sha1hash = "" |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
272 |
#octalWordList = record.trustSha1Hash.split("\\") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
273 |
for index in range(0, len(record.trustSha1Hash)): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
274 |
hexdigits = hex(ord(record.trustSha1Hash[index]))[2:] |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
275 |
hexdigits = hexdigits.zfill(2) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
276 |
sha1hash = sha1hash + hexdigits + " " |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
277 |
outFileSym.write("\t# Thumbprint(hex) %s\n" % sha1hash) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
278 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
279 |
outFileSym.write("\tStartEntry " + record.certLabel + "\n") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
280 |
outFileSym.write("\t\tDeletable true\n") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
281 |
outFileSym.write("\t\tFormat EX509Certificate\n") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
282 |
outFileSym.write("\t\tCertOwnerType ECACertificate\n") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
283 |
outFileSym.write("\t\tSubjectKeyId auto\n") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
284 |
outFileSym.write("\t\tIssuerKeyId auto\n") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
285 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
286 |
# Write out trust details |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
287 |
outFileSym.write("\t\tStartApplicationList\n") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
288 |
for trust in record.trustTrustList: |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
289 |
# Look for the mapping |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
290 |
for mapping in trustMapping: |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
291 |
if (trust == mapping[0]): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
292 |
# Found a mapping. Add it and keep on looking since |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
293 |
# there could be more than one app mapping |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
294 |
outFileSym.write('\t\t\tApplication "' + mapping[2] + '"\n'); |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
295 |
outFileSym.write("\t\tEndApplicationList\n") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
296 |
outFileSym.write("\t\tTrusted true\n") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
297 |
certFileName = "certs\\\\cert%04d" % outRecNum + ".der" |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
298 |
outFileSym.write('\t\tDataFileName "' + certFileName + '"\n') |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
299 |
outFileSym.write("\tEndEntry\n\n") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
300 |
# Write the certificate file |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
301 |
outFileCert = open(outPath + certFileName, "wb") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
302 |
outFileCert.write(record.certData) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
303 |
outFileCert.close() |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
304 |
print ".", |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
305 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
306 |
if (outRecNum > 0): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
307 |
outFileSym.write("EndCertStoreEntries\n") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
308 |
outFileSym.close() |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
309 |
print "done." |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
310 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
311 |
# Finally create the app to uid mapping file for Symbian OS |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
312 |
if (outRecNum > 0): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
313 |
outFileSym = open(outPath + outFileCertClients, "w") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
314 |
outFileSym.write("StartClientInfo\n") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
315 |
for index in range(0, len(trustMapping)): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
316 |
outFileSym.write("\t#Entry %d\n" % (index + 1)) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
317 |
outFileSym.write("\t\tUid %s\n" % trustMapping[index][1]) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
318 |
outFileSym.write('\t\tName "%s"\n' % trustMapping[index][2]) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
319 |
outFileSym.write("EndClientInfo\n") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
320 |
outFileSym.close() |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
321 |
inFileMoz.close() |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
322 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
323 |
print "Invoking certapp tool to create the Symbian certificate store...", |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
324 |
certappCmd = "certapp" + \ |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
325 |
" --in --hca=" + outPath + outFileCaCerts + " --hcc=" + outPath + outFileCertClients + \ |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
326 |
" --out --bca=" + outPath + "cacerts.dat" + " --bcc=" + outPath + "certclients.dat" |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
327 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
328 |
dummyFile = open(outPath + outCertAppOutput, "w") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
329 |
p = subprocess.Popen(certappCmd, 0, None, None, dummyFile, dummyFile) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
330 |
retcode = p.wait() |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
331 |
dummyFile.close() |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
332 |
|
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
333 |
if (retcode != 0): |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
334 |
print "\ncertapp returned error code: %d" % retcode |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
335 |
print certappCmd |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
336 |
print "For details see file " + outPath + outCertAppOutput |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
337 |
print "Leaving temp files untouched for debugging" |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
338 |
else: |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
339 |
print "done." |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
340 |
print "Cleaning up temp files...", |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
341 |
files = glob.glob(outPath + "certs\\*") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
342 |
for file in files: |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
343 |
os.remove(file) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
344 |
os.rmdir(outPath + "certs") |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
345 |
os.remove(outPath + outFileCaCerts) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
346 |
os.remove(outPath + outFileCertClients) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
347 |
os.remove(outPath + outCertAppOutput) |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
348 |
print "done." |
8e4b1aa36db9
Added python script to import Mozilla certificates into Symbian OS (Bug 287). Also added the Mozilla certificate store file.
Santosh V Patil <santosh.v.patil@nokia.com>
parents:
diff
changeset
|
349 |
print "Done. Read %d" % inRecNum + " certificates. Written %d" % outRecNum + " certificates.\n" |