|
>>4010 68user ご迷惑をお掛けしまして、大変申し訳ありません。 プログラム名ですが、[POST hoge HTTP/1.0] という感じで、 設定しております。 以下がソースになります。 +−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+ #include <stdio.h> #include <string.h> #include <sys/types.h> #include <netdb.h> #include <sys/socket.h> #include <netinet/in.h> #include <sys/types.h> #include <sys/uio.h> #include <unistd.h> #include <openssl/crypto.h> #include <openssl/x509.h> #include <openssl/pem.h> #include <openssl/ssl.h> #include <openssl/err.h> #define EXT_OK 0 #define EXT_ERR -1 #define LINE_MAX_LEN 512 #define FILE_PATH_LEN 256 #define SEND_XML_LEN 640 #define RECV_VAL_LEN 256 #define SEND_VALUE "xml=送信データ" int main(int argc ,char *argv[]) { int ierr = 0; int isockt = 0; int read_size = 0; struct hostent *servhost; // サーバ情報構造体 struct sockaddr_in server; // ソケット構造体 struct servent *service; // サービス構造体 SSL *ssl; SSL_CTX *ctx; char *str; char send_buf[SEND_XML_LEN + 1]; // 送信データ char request[SEND_XML_LEN + 1]; // ヘッダー char total_buf[RECV_VAL_LEN + SEND_XML_LEN + 1]; // 送信データ(ヘッダー + データ) char *host = "接続先ホスト名"; // サーバ名セット char *path = "CGIパス"; // CGI名セット char buf[RECV_VAL_LEN]; memset(send_buf,'\0',sizeof(send_buf)); memset(request,'\0',sizeof(request)); memset(total_buf,'\0',sizeof(total_buf)); servhost = gethostbyname(host); if ( servhost == NULL ) { fprintf(stderr, "[%s] から IP アドレスへの変換に失敗しました。\n", host); exit( EXT_ERR ); } bzero((char *)&server, sizeof(server)); server.sin_family = AF_INET; bcopy(servhost->h_addr, (char *)&server.sin_addr, servhost->h_length); service = getservbyname("https", "tcp"); // ポート番号取得 if ( service != NULL ) { server.sin_port = service->s_port; } else { server.sin_port = htons(443); // 取得できなかったら、ポート番号を 443 に決め打ち } isockt = socket(AF_INET, SOCK_STREAM, 0); if ( isockt < 0 ) { fprintf(stderr, "ソケットの生成に失敗しました。\n"); exit( EXT_ERR ); } if ( connect(isockt, (struct sockaddr*) &server, sizeof(server)) == -1 ) { fprintf(stderr, "connect に失敗しました。\n"); exit( EXT_ERR ); } SSL_library_init(); // SSLのライブラリを初期化 SSL_load_error_strings(); // SSLエラーメッセージ Catch ctx = SSL_CTX_new(SSLv23_client_method()); // SSLv2を使用 ssl = SSL_new(ctx); SSL_set_fd(ssl, isockt); // SSLとソケットの関連付け ierr = SSL_connect(ssl); sprintf(send_buf,"%s",SEND_VALUE); sprintf(request, "POST %s.cgi HTTP/1.0\r\n" "User-Agent: Mozilla/4.0 (compatible; MSIE 5.0; Windows NT 5.0)\r\n" "Content-Length: %d\r\nContent-type: text/xml; " "charset=utf-8\r\n\r\n",argv[0],strlen(send_buf)); sprintf(total_buf,"%s%s",request,send_buf); ierr = SSL_write(ssl, total_buf, strlen(total_buf)); printf("サーバからのレスポンス\n"); while (1) { memset(buf,'\0',sizeof(buf)); read_size = 0; read_size = SSL_read(ssl, buf, sizeof(buf)-1); buf[read_size] = '\0'; if ( read_size > 0 ) { write(1, buf, read_size); } else { break; } } SSL_shutdown(ssl); close(isockt); // ソケットクローズ SSL_free(ssl); SSL_CTX_free(ctx); exit( EXT_OK ); } +−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−+ 申し訳ありませんが、ご教授ください。 宜しくお願いします。 |
|
>>4011 くろ SSL/TLS 以前の問題に見えます。http://X68000.q-e-d.net/~68user/net/ の HTTP クライアントを作ってみよう(1)〜(4) を読んでください。 |
|
>>4012 68user ご指摘ありがとうございました。 なんと接続することができました。 ご迷惑をお掛けしまして、申し訳ありません。 |
|
環境変数にセットする値をConfigFileから読み込む仕様のシェルがあります。 しかし今その環境変数の値にスペースがある場合にうまく動きません。 具体的には configFile内に T_DATE=`date +'%Y%m%d%H%M%S'` と記述して実際のBシェルの中で for var in `cat ${CONFIG}` do export $var done としています。 想定としては export T_DATE=`date +'%Y%m%d%H%M%S'` となってほしいのですが 実際には export T_DATE=`date export +'%Y%m%d%H%M%S'`=+'%Y%m%d%H%M%S'` という2つの変数として扱われてしまいます。 これを回避する方法はありませんでしょうか。 使用している環境はHP-UX B.11.11 です。 |
|
>>4014 どんぐ while read line; do eval $line done < ${CONFIG} てな感じでどうでしょうか。 |
|
Vacancies in SUN China In 1982 Sun Microsystems created a business vision named “The Network is the Computer”. In the same year Sun initiated R&D on Java Technology. Today Sun is recognized by all as the Premier Network Enterprise Computing Vendor and have a global presence in over 100 countries. In 1987, Sun entered China market and has been dedicated to the technology and customer solution development in China. Customer Solution Center in Beijing expand repidly to provide technical hot line suppot to mission critical customers. We invite top nortch engineers to join our champion team in Beijing to provide world-class customer services. Solution Center Engineer (GC0201938) (53 Vacancies) UNIX generalist responsible for providing system support that includes hardware, software, software applications, and networking to customers via telephone support. Incumbent must be university graduate in Computer Science / Electronic Engineering, knowledgable in O/S like Unix, Linux or Solaris systems, fluent in written and spoken Japanese and with minimum 3 years of Unix Sever Support, System Integration or internal MIS support of Unix Sever. Solution Center Manager (GC0201941) (2 Vacancies) Manages and directs the activities of the Solution Center teams to provide customer facing technical post sales support of both hardware and software issues. Accountable for meeting operational excellence, customer satisfaction and people management goals of Solution Center. Liaise closely with the product technical support group for technical escalation as well as the local field operations. Incumbent must be Universtiy graduate in Computer Science / Electronics Engineering, 10 years customer support experience with 5 years in managerial capacity and fluent in written and spoken Japanese, good English is a plus. To apply this position, Please send your resume in English, Mandarin or Japanese and marked with position code to Lisa.wu@multimage.com.cn. Contact: Tel: +86 10-65057881-17 Lisa 84580901-17 Lisa Mob: 13501160969 Fax: +86 10-65057880/84583069 |