Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Side by Side Diff: client/cros/ownership.py

Issue 6759063: [autotest] Update login_OwnershipApi to use protobufs (Closed) Base URL: http://git.chromium.org/git/autotest.git@master
Patch Set: make fixes Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « client/cros/constants.py ('k') | client/site_tests/login_OwnershipApi/login_OwnershipApi.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging, os, tempfile 5 import logging, os, tempfile
6 from autotest_lib.client.bin import utils 6 from autotest_lib.client.bin import utils
7 from autotest_lib.client.common_lib import autotemp, error 7 from autotest_lib.client.common_lib import autotemp, error
8 import common 8 import common
9 import constants, cryptohome, login 9 import constants, cryptohome, login
10 10
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 def pairgen(): 59 def pairgen():
60 """Generate a self-signed cert and associated private key. 60 """Generate a self-signed cert and associated private key.
61 61
62 Generates a self-signed X509 certificate and the associated private key. 62 Generates a self-signed X509 certificate and the associated private key.
63 The key is 2048 bits. The generated material is stored in PEM format 63 The key is 2048 bits. The generated material is stored in PEM format
64 and the paths to the two files are returned. 64 and the paths to the two files are returned.
65 65
66 The caller is responsible for cleaning up these files. 66 The caller is responsible for cleaning up these files.
67 """ 67 """
68 keyfile = scoped_tempfile.tempdir.name + 'private.key' 68 keyfile = scoped_tempfile.tempdir.name + '/private.key'
69 certfile = scoped_tempfile.tempdir.name + 'cert.pem' 69 certfile = scoped_tempfile.tempdir.name + '/cert.pem'
70 cmd = '%s -x509 -subj %s -newkey rsa:2048 -nodes -keyout %s -out %s' % ( 70 cmd = '%s -x509 -subj %s -newkey rsa:2048 -nodes -keyout %s -out %s' % (
71 OPENSSLREQ, '/CN=me', keyfile, certfile) 71 OPENSSLREQ, '/CN=me', keyfile, certfile)
72 system_output_on_fail(cmd) 72 system_output_on_fail(cmd)
73 return (keyfile, certfile) 73 return (keyfile, certfile)
74 74
75 75
76 def push_to_nss(keyfile, certfile, nssdb): 76 def push_to_nss(keyfile, certfile, nssdb):
77 """Takes a pre-generated key pair and pushes them to an NSS DB. 77 """Takes a pre-generated key pair and pushes them to an NSS DB.
78 78
79 Given paths to a private key and cert in PEM format, stores the pair 79 Given paths to a private key and cert in PEM format, stores the pair
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 except: 157 except:
158 err.fo.seek(0) 158 err.fo.seek(0)
159 logging.error(err.fo.read()) 159 logging.error(err.fo.read())
160 raise 160 raise
161 161
162 sig.fo.seek(0) 162 sig.fo.seek(0)
163 sig_data = sig.fo.read() 163 sig_data = sig.fo.read()
164 if not sig_data: 164 if not sig_data:
165 raise error.TestFail('Empty signature!') 165 raise error.TestFail('Empty signature!')
166 return sig_data 166 return sig_data
167
OLDNEW
« no previous file with comments | « client/cros/constants.py ('k') | client/site_tests/login_OwnershipApi/login_OwnershipApi.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698