Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
emulab
emulab-devel
Commits
cd191e4d
Commit
cd191e4d
authored
Feb 15, 2012
by
Leigh B Stoller
Browse files
Add CommonName() and SubjectHash() methods.
parent
5b4d70cd
Changes
1
Hide whitespace changes
Inline
Side-by-side
protogeni/lib/GeniCertificate.pm.in
View file @
cd191e4d
#
!/usr/bin/perl -wT
#
#
GENIPUBLIC
-
COPYRIGHT
#
Copyright
(
c
)
2008
-
201
1
University
of
Utah
and
the
Flux
Group
.
#
Copyright
(
c
)
2008
-
201
2
University
of
Utah
and
the
Flux
Group
.
#
All
rights
reserved
.
#
package
GeniCertificate
;
...
...
@@ -750,6 +750,37 @@ sub asText($)
return
join
(
""
,
@
certlines
);
}
sub
SubjectHash
($)
{
my
($
self
)
=
@
_
;
my
@
result
=
$
self
->
PipeTo
(
0
,
"$OPENSSL x509 -subject_hash -noout"
);
if
(
! @result) {
print
STDERR
"Could not convert $self to subject hash
\n
"
;
return
undef
;
}
my
$
hash
=
$
result
[
0
];
if
($
hash
=~
/^(\
w
*)$/)
{
return
$
1
;
}
print
STDERR
"Bad sha1 value for $self
\n
"
;
return
undef
;
}
sub
CommonName
($)
{
my
($
self
)
=
@
_
;
my
@
parts
=
split
(
'/'
,
$
self
->
DN
());
foreach
my
$
part
(@
parts
)
{
my
($
key
,$
val
)
=
split
(
'='
,
$
part
);
if
($
key
eq
"CN"
)
{
return
$
val
;
}
}
return
undef
;
}
sub
sha1
($)
{
my
($
self
)
=
@
_
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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