Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
emulab
emulab-devel
Commits
55e39fab
Commit
55e39fab
authored
Jul 29, 2011
by
Leigh B Stoller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a routine to load a private key from a file, and associate with
certificate object.
parent
f99845c0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
protogeni/lib/GeniCertificate.pm.in
protogeni/lib/GeniCertificate.pm.in
+51
-0
No files found.
protogeni/lib/GeniCertificate.pm.in
View file @
55e39fab
...
...
@@ -817,6 +817,57 @@ sub DeleteCRL($$)
return
0
;
}
#
#
Load
a
key
from
a
file
and
associate
with
the
certificate
object
.
#
sub
LoadKeyFromFile
($$)
{
my
($
self
,
$
filename
)
=
@
_
;
if
(
!open(KEY, $filename)) {
print
STDERR
"Could not open file: $filename
\n
"
;
return
-
1
;
}
my
$
privkey
;
my
$
string
;
while
(<
KEY
>)
{
my
$
line
=
$
_
;
if
($
line
=~
/^-----
BEGIN
RSA
/)
{
$
string
=
""
;
next
;
}
if
($
line
=~
/^-----
END
RSA
/)
{
$
privkey
=
$
string
;
$
string
=
undef
;
next
;
}
$
string
.=
$
line
if
(
defined
($
string
));
}
close
(
KEY
);
if
(
!defined($privkey)) {
print
STDERR
"No private key found in $filename
\n
"
;
return
-
1
;
}
$
self
->{
'CERT'
}->{
'privkey'
}
=
$
privkey
;
return
0
;
}
sub
WriteKeyToFile
($)
{
my
($
self
)
=
@
_
;
#
We
want
this
file
to
be
passed
back
.
my
($
tempfile
,
$
filename
)
=
tempfile
(
UNLINK
=>
1
);
print
$
tempfile
"-----BEGIN RSA PRIVATE KEY-----
\n
"
;
print
$
tempfile
$
self
->
privkey
();
print
$
tempfile
"-----END RSA PRIVATE KEY-----
\n
"
;
return
$
filename
;
}
############################################################################
#
#
Wrapper
for
local
users
.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment