File: checkmsva.c

package info (click to toggle)
libmsv 1.0-1~bpo70+1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 1,408 kB
  • sloc: sh: 11,093; ansic: 395; makefile: 104
file content (73 lines) | stat: -rw-r--r-- 3,386 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* checkmsva: MonkeySphere Validation library test program
 *   Copyright © 2011-2013  Clint Adams

 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
*/

#include <stdlib.h>
#include <stdio.h>

#include "msv/msv.h"

int
main (int argc, char **argv)
{
  int x;
  msv_ctxt_t ctx;
  struct msv_query query;
  struct msv_response *response;

  ctx = msv_ctxt_init (NULL);

  x = msv_check_msva (ctx);
  printf ("MSVA check: %s\n", msv_strerror (ctx, x));

  query.context = "https";
  query.peertype = "server";
  query.peername = "www.softwarefreedom.org";
  query.pkctype = "x509pem";
  query.pkcdata = "-----BEGIN CERTIFICATE-----\n"
    "MIIE7DCCA9SgAwIBAgIRAPBGJ9FB7isLF2bGpDQ0SQ4wDQYJKoZIhvcNAQEFBQAw\n"
    "QTELMAkGA1UEBhMCRlIxEjAQBgNVBAoTCUdBTkRJIFNBUzEeMBwGA1UEAxMVR2Fu\n"
    "ZGkgU3RhbmRhcmQgU1NMIENBMB4XDTExMDMyMjAwMDAwMFoXDTEyMDMyMTIzN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\n"
    "Z2FuZGkubmV0L0dhbmRpU3RhbmRhcmRTU0xDQS5jcnQwIQYIKwYBBQUHMAGGFWh0\n"
    "dHA6Ly9vY3NwLmdhbmRpLm5ldDA3BgNVHREEMDAughd3d3cuc29mdHdhcmVmcmVl\n"
    "ZG9tLm9yZ4ITc29mdHdhcmVmcmVlZG9tLm9yZzANBgkqhkiG9w0BAQUFAAOCAQEA\n"
    "P1DcKGoP2cfAUGxT6N8BLVKib7wrhsqhy4u5+7sZyBSdo0r6MsyOqw+J68bcx7wZ\n"
    "v7/khnx53Qgh3Xm97QXmua6c89BsQkr4EdWiKyu1bNimXksmtiUlkCiC63vakjrQ\n"
    "IJroa64ATbxEXoJa6HgQNCZHLRAwPecD7eCiwyUX7KZG8dnC5983FbtP+RD647P8\n"
    "Nhv5d9fALco89VqiVHSNSuMIrd83q+6T5ecK+Z9e3GkAqTIbrosV0TXtGO7iuW9G\n"
    "xHMcOGjzfj0LUSqVEVe/D8VzeTEQiNs1MVuRtpQ/dciEL2dkXqjzZiuuhs6TIvDG\n"
    "6wknKthAJdFSXGQkb7kGiw==\n" "-----END CERTIFICATE-----\n";
  x = msv_query_agent (ctx, query, &response);
  printf ("MSV query: %s\nValid: %s\nMessage: %s\n", msv_strerror (ctx, x),
	  response->valid ? "true" : "false", response->message);

  exit (x);
}