$Sock_Cert_Info
Value of entity in partner's certificate
Note: Most Sirius $functions have been deprecated in favor of Object Oriented methods. There is currently no direct OO equivalent for this $function.
$Sock_Cert_Info retrieves the value of an entity for one of the levels of the certificate provided on a socket by the remote partner.
Syntax
%string = $Sock_Cert_Info(socket, entity, [level])
Syntax terms
%string | The value of the requested entity at the requested level of the certificate supplied by the remote partner. If no such certificate was provided, the null string is returned. |
---|---|
socket | A string that is the socket identifier. |
entity | The name of the requested entity. Valid values are described below. |
level | The certificate level at which to obtain the entity: Level 0 corresponds to the client or the "subject" of the certificate; level 1 corresponds to the "signer" of the certificate; level 2 corresponds to the "signer" of the level 1 signer's certificate; and so on.
This argument is optional; the default value is 1. For more information about certificate levels, see the Janus Network Security Reference Manual. |
Certificate entities
The following entities can be requested with $Sock_Cert_Info:
COMMONNAME | Any name used to identify the client. Could be a first name/last name, an ID number, or even a userid. COMMONNAME can be abbreviated CN, CNAME, or COMMONN. |
---|---|
ORGANIZATIONALUNIT | The department or section of the organization to which the user belongs. For example, "Physics Department,"Accounts receivable," or "Web doods." ORGANIZATIONALUNIT can be abbreviated ORGU, ORGANIZATIONALU, or ORGUNIT. |
ORGANIZATION | The company, government agency, school, or other organization to which the client belongs. For example, "Hard Knocks University," "Effete Recordings," or "bagsofconcrete.com." ORGANIZATION can be abbreviated ORG. |
LOCALITY | The city, town, or village in which the subject resides or works. LOCALITY can be abbreviated LOC. |
STATE | The state, province, or other intermediate governmental unit in which the subject resides or works. PROVINCE is a synonym for STATE. |
COUNTRY | The country or nation in which the subject resides or works. |
VALIDITYDATE | The date on which the subject's or signer's certificate became valid. Janus Network Security will not accept a client certificate where the subject's or signer's certificate is not yet valid, so use of this field is largely informational.
VALIDITYDATE is returned as a date string in |
EXPIRATIONDATE | The date on which the subject's or signer's certificate becomes invalid. Janus Network Security will not accept a client certificate where the subject's or signer's certificate is no longer valid, so use of this field is largely informational, though it might prove useful in providing a warning to a user whose certificate is going to expire soon.
EXPIRATIONDATE can be abbreviated EXPIRYDATE, EXPDATE, or EDATE, or it can be requested as EXPIRATIONTIME, EXPIRYTIME, EXPTIME, or ETIME. |
SERIALNUMBER | The serial number of the subject's certificate as assigned by the signer. Certifying authorities should assign a unique serial number to each certificate they sign. The assigned serial number could be a number that goes up by one for each certificate signed by a certifying authority, or it could be a number derived from the date and time, for example.
SERIALNUMBER is returned as a hexadecimal string with an even number of hexadecimal digits. Since the signer's certificate is generally "self-signed," it often does not have a serial number, that is, the level 1 serial number is usually returned as a null. While SERIALNUMBER doesn't have any particular significance from an application level, it can be used as an extra piece of identifying information for a client certificate. SERIALNUMBER can be abbreviated SERIALNUM, SERNUMBER, SERNUM, SERIAL or SER. |
PRIVATEKEYLENGTH | The length of the private key used by the signer or the client. Private key lengths are usually expressed in terms of number of bits, so PRIVATEKEYLENGTH returns a decimal number string, such as "512" or "1024".
This value could be used to determine a "level of trustworthiness" of a client certificate, where a 512-bit certificate is considered somewhat weak (though probably strong enough for all but the most extreme security requirements), and a 1024-bit certificate is considered strong. Janus Network Security will not accept certificates that indicate private keys shorter than 512 bits or longer than 2048 bits. Generally, client certificates use either a 512-bit or a 1024-bit key. PRIVATEKEYLENGTH can be abbreviated PRIVATEKEYL, PKEYLENGTH, or PKEYL. |
TEMPORARYKEYLENGTH | The length of the temporary or "ephemeral" private key. Since SSL client certificate support does not cover ephemeral private keys, and in fact, such support would be largely meaningless anyway, TEMPORARYKEYLENGTH always returns a 0
($Sock_Cert_Info) or Socket object method (CertInfo). TEMPORARYKEYLENGTH can be abbreviated TEMPORARYKEYL, TEMPKEYLENGTH or TEMPKEYL. |
PERMANENTKEYLENGTH | The length of the permanent private key. Since SSL client certificate support does not cover ephemeral private keys, and in fact, such support would be largely meaningless
anyway, PERMANENTKEYLENGTH always returns a the same value as PRIVATEKEYLENGTH. It is simply included here for compatibility with the equivalent Janus Sockets function ($Sock_Cert_Info) or Socket object method (CertInfo). PERMANENTKEYLENGTH can be abbreviated PERMANENTKEYL, PERMKEYLENGTH, or PERMKEYL. |
MD5HASH | The MD5 hash or "digest" of the subject or issuer certificate. The MD5 hash of a certificate is shown by some browsers when displaying certificate information. An MD5 hash is always a 16-byte value, so MD5HASH always returns a 32-character hexadecimal string.
Since it is basically impossible for any two different certificates to have the same MD5 hash, the MD5HASH value can be used in and of itself as a unique identification of a certificate. That is, if certificate information is stored in a database, the MD5 hash of the certificate can be used a primary unique key to locate the certificate. MD5HASH can be abbreviated MD5. |
SHAHASH | The SHA hash or "digest" of the subject or issuer certificate. The SHA hash of a certificate is shown by some browsers when displaying certificate information. An SHA hash is always a 20-byte value, so SHAHASH always returns a 40-character hexadecimal string.
Since it is basically impossible for any two different certificates to have the same SHA hash, the SHAHASH value can be used in and of itself as a unique identification of a certificate. That is, if certificate information is stored in a database, the SHA hash of the certificate can be used a primary unique key to locate the certificate. SHAHASH can be abbreviated SHA. |
Usage notes
- $Sock_Cert_Info returns the null string if the socket is not open
and ONRESET CONTINUE is in effect for the socket.
For example, this statement returns the name of the organization at level 1
of the certificate provided by the partner that sent the request for the server (SRVSOCK) socket:
%org = $Sock_Cert_Info(1, 'ORGANIZATION', 1)
- As of Sirius Mods 7.7,
if a Janus SSL server program issues $Sock_Cert_Info or $Sock_Cert_Levels,
the returned string will be null if
the server port definition includes the SSLCLCERT or SSLCLCERTR parameter.
Those JANUS DEFINE parameters cause a request for a client certificate in the
initial server-client handshake that establishes the SSL connection.
The $Sock_Cert_Info or $Sock_Cert_Levels call in this case would be a second
request for a certificate,
and a client certificate may only be requested once for an SSL session
(whether or not the request successfully gets a certificate in return).
If neither of those JANUS DEFINE parameters are specified, a server's $Sock_Cert_Info or $Sock_Cert_Levels call will cause an SSL renegotiation (that is, a new handshake) that requests a digital certificate from the client. This allows a port to require a client certificate for some content, but not for other content.
In the renegotiation, the server requests a certificate, but does not insist that the client present one. The returned string from the method call may therefore still be null because no certificate was provided.
If another function or method causes a renegotiation by requesting a client certificate, a subsequent $Sock_Cert_Info or $Sock_Cert_Levels call will not cause another request for a client certificate, whether or not a client certificate was returned for the initial renegotiation. This is because:
- There is no reason a client would not return a certificate on an initial renegotiation, but return a certificate on a later renegotiation.
- There is no reason a client would return a certificate on an initial renegotiation, then return a different client certificate on a subsequent SSL renegotiation.